Are there BUT or OR statements?

For example:

[[section]]:

'Oooh! Jam!'

[[Take Jam]]
[[Take Jam]]:
[Eat Jam] or [Save Jam]

[Eat Jam]:
{if seen Take Jam:'Yummy!'}{else:You don't have jam}

[Save Jam]:

[Eat Jam](boop) or [Throw Jam Away]

[boop]:
{if seen Take Jam:'Yummy!'}{but if seen Eat Jam or Throw Jam Away:You don't have jam}{else:You don't have jam}

[Throw Jam Away]:
You threw the jam away.

?


Your but construct is weird - it would be impossible to add that with Squiffy as it currently stands, because it would need to look at all of the code in a text section before displaying any of it. At present, when squiffy sees {if, it processes the condition, displays its contents or doesn't, and then moves on to the next bit (storing a little data in case of an {else. But your structure seems to assume that {but can make it go back and change a part that has already been displayed.

However, if I understand correctly, your construct:

{if A:B}{but if C:D}

could be rearranged as:

{if A:{if C:D}{else:B}}

That allows the blocks to be processed in the order the interpreter sees them. It seems to do the same thing.

It's been suggested before that there should be an or operator… I think it would be a good idea, but it's not currently an option. For now I think you will need to have some of your 'else' clauses repeated, or use temporary attributes to keep track of stuff like that. Or use javascript.

Example:

{if seen Take Jam:{@has_jam}}
{if seen Eat Jam:{@not has_jam}}
{if seen Throw Jam Away:{@not has_jam}}
{if has_jam:‘Yummy!’}{else:You don't have jam.}

or using javascript:

    squiffy.story.set('has_jam', squiffy.story.seen('Take Jam') and not (squiffy.story.seen('Eat Jam') or squiffy.story.seen('Throw Jam Away')))
{if has_jam:‘Yummy!’}{else:You don't have jam.}

Or more logically, for an inventory system:

[[section]]:

'Oooh! Jam!'

[[Take Jam]]
[[Take Jam]]:
@set has_jam
[Eat Jam] or [Save Jam]

[Eat Jam]:
@set not has_jam
{if seen Take Jam:'Yummy!'}{else:You don't have jam}

[Save Jam]:

[Eat Jam](boop) or [Throw Jam Away]

[boop]:
{if has_jam:'Yummy!'}{else:You don't have jam}

[Throw Jam Away]:
@set not has_jam
You threw the jam away.

Doing it like that means that if you later decide the player can use the jam somewhere else, you don't need to go back and change the if statements everywhere the jam is checked for.


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums