Have widget prevent any output beneath it

Twine Version: 2.9.2

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?

Hi there,
That’s because “You survive by hiding behind a boulder” is not included in your widget. As you’ve coded it it will always appear.

To give you the best answer, it would be best if you could share your <<checkdamage>> widget code.

But you would want essentially to have:

<<if $health < 1>>
    <<include "death">>
<<else>>
     "You survive by hiding behind a boulder"
     [Rest of your passage]
<</if>>

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.

To explain it better, I’m trying to find a way to pull off a “goto” command that does terminate passage rendering.

Nvm I misunderstood the q lol


tag the death screen passage with something like death and use the passage tags code in your widget’s if block like manon suggested.

(not tested)

<<if !tags().includes("death")>>
You survived etc
<</if>>

The ! means “not”. so “if your passage’s tags do not include the tag “death”, display the you survived text”

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:

<<link "Attack">>
    <<checkDamage>>
    <<if _death is true>>
         <<goto "death">>
    <<else>>
         <<goto "Next Passage">>
    <</if>>
<</link>>

The death passage being its own screen.

1 Like