I'm trying to create a game where the player can select multiple classes each year to add to their course load. Is that possible in Squiffy? Is there any way to list out a bunch of courses and have the player select multiple and then add them to a course list?
You could also do it using passages- depends on how tough you want to make this. You could do something like this.
[[Pick a class]]:
It's time to pick your classes!
[Math]
[Computing]
[[Head to class]](end)
[Math]:
You are now signed up for math. It's pretty tough.
[Computing]:
Maybe you could learn crazy languages here!
[[end]]:
Head to class!
Of course, more code could be added to the passages to remember what you have.
It's been a while, but thought I would add something...
If you are using passages, then you'll want to add in a [@3]
or something too if you want to limit how many options they can choose.
For example:
[[Pick classes]]:
set('classes', [])
Hello student!
Choose three classes to enrol in:
[English]
[Maths]
[Physics]
[Chemistry]
[Computing]
[English]:
set('classes', get('classes').concat('English'))
You have enrolled in English. It will probably involve poetry and classic literature at least. Which might be enough to make up for the essays.
[Maths]:
set('classes', get('classes').concat('Maths'))
You have enrolled in Mathematics. The only field that everyone on the planet uses in daily life.
[Physics]:
set('classes', get('classes').concat('Physics'))
You have enrolled in Physics. Maybe you'll get to cause things to crash into each other.
[Chemistry]:
set('classes', get('classes').concat('Chemistry'))
You have enrolled in Chemisty. With any luck there'll be explosions.
[Computing]:
set('classes', get('classes').concat('Computing'))
You have enrolled in Computing. Programming in lots of different languages is fun!
[@3]:
squiffy.story.go('next')
[[next]]:
<hr>
Your classes have been chosen.
You are enrolled in {classes}.
You can test the code out in the editor or scratchpad.
I added in some Javascript to remember chosen classes, but you could use the "normal" Squiffy attributes of @set enrolledPhysics
and {if enrolledPhysics:You are enrolled in Physics}
instead if you don't want to have to deal with crazy javascript stuff.
The only javascript you need is the line in the [@3]
passage that sends them to the next section.
So, main points:
squiffy.story.go('section')
line.[@3]
, [@4]
, etc. to limit the number of options chosen to whatever number you feel like.Your writing impresses me deeply, and I hope you will have more good articles in the future to give readers a new perspective on life.
run 3