Is this a bad idea?

I've got some code I need to write. In this section, we check to see if something actually happened. If it didn't, I just want to skip it and return to the game section. Otherwise, I need to do traditional squiffy text. So I'm trying this...

    if (a){squiffy.story.go("game section");}

{if not a:
blah blah blah

[[Okay, you saw it. We're done]](game section)

So, am I asking for it or not?

Idk much as I'm kinda new but I do think using JS then using @clear makes stuff kinda wonky you could use the JS ver of @clear which is :


If it's a passage, I think that should work fine.

If it's a section, you don't need the {if not a: condition, because of how Squiffy processes pages:

  1. Mark the section as seen
  2. Do steps 3-5 for the master section
  3. Process attributes (@ lines)
  4. Run javascript
  5. If the _section attribute equals this section name:
    • Display the text part
    • Save progress

In your example, calling squiffy.story.go will change the value of _section (the current section name), so the text part of that section will only be displayed if 'a' didn't happen

Well, the problem with that is that my games are circular and reusable, so I'm afraid marking something as seen will bite me if I come back around and try to use the code. This code appears in a multiply-used section.

I'm just afraid that if I am using the {@a=1} sort of code down in the squiffy section, it will still get executed even though I'm not going into it. I'm used to logical flows and squiffy sections make multiple passes, often with unintended consequences.

It does have some oddities. For example, if you do ``@set _section = some_other_section`, it will run the JS and then not display the text (nor will some_other_section be displayed).

But if the JS calls squiffy.story.go, it will run the page it's been sent to, then the remainder of the JS on this page, and stop without displaying this section's text.

The thing to keep in mind is that the sequence I summarised happens inside squiffy.story.go, so the remainder of the JS after that function call will come after the output from the page you're being sent to.

Yeah, that's bitten me in the butt before - I figured it jumped out but no, it branches. That's why I put it on the bottom and made sure I didn't execute the squiffy. I think I've actually moved away from this method...

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