I have a widget in my game to check if someone is out of health. If they are, they’re supposed to die and load the “death” page. Problem is, if I use <<include "death">> to make it load the death page, it will load that in the middle of the scene. So if the scene looks like:
"Greg attacks you, dealing 4 fire damage"
<<checkdamage 1>>
"You survive by hiding behind a boulder"
checkdamage would see if the user has 1 health or more. If they don’t, it will load the “death” page. Problem is, it will load the “You survive by hiding behind a boulder” content even if the character dies, so it loads the death game over screen like this:
"Greg attacks you, dealing 4 fire damage"
You have died.
[Game Over Button, loading the restart of the game]
"You survive by hiding behind a boulder"
How can I make it break any other content so it doesn’t show anything after loading the “death” page?
Shoot, because I have lots and lots and lots of content on pages below widgets. I run the damage check multiple times in one page. In choicescript I was able to avoid the issue by using a goto to break the narrative display and only show the death page. The focus here is less on what’s in the widget and more on breaking any display that comes after it.
The instant a new passage is called, it will be called at a whole.
So if there’s a game over check in the middle of the page you’ll have to work to be sure whatever is beyond do not appear. The easier way is to wrap it in an <<if>><</if>> macro.
Assuming the button to the dead scene is in the widget.
"Greg attacks you, dealing 4 fire damage"
<<checkdamage 1>>
<<if $Whatevervariablestatingyourestillalive>>"You survive by hiding behind a boulder"<</if>>
Yeah… *goto in ChoiceScript is not <<goto>> in SugarCube (made a whole guide with a equivalence to help). *goto is closest to <<include>>.
You can’t “stop” a passage from rendering like ChoiceScript does. Only use conditional statements to display either possibilities.
What you can do is: edit your <<checkdamage>> widget in the way that it only checks for the damage:
<<if $health < 1>>
<<set _dead to true>>
<</if>>
And in your passage itself, after each check:
<<if _death>>
<<include "death>>
<<else>>
[the rest of your passage]
<</if>>
You might end up with something like:
Lorem ipsum
<<checkDamage>>
<<if _death>>
<<include "death>>
<<else>>
Lorem Ipsum
<<checkDamage>>
<<if _death>>
<<include "death>>
<<else>>
Lorem Ipsum [[Next]]
<</if>>
<</if>>
Another way, can be done through links: as in, instead of having the checks in the passage, it’s done while the player makes a choice: