Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

If - need help

Hi everyone,

I'm building my first text adventure in Twine so apologies if this is something super basic that I haven't been able to grasp.

In my story I have both $HEALTH and $MORALITY which vary as you make choices and move through passages. I've managed to set $HEALTH and $MORALITY and I have figured out how to +/- both in the passages BUT:

When  <<if $HEALTH < 1>> i.e. when the player dies due to his/her choices, I want the passage the player has died on to:

Display some text about the death in that particular passage AND remove the live links which are in the passage in case you do not die.

How do I do that? At the end of my (possible death) passages I have e.g.:

<<set $HEALTH = $HEALTH -40>>

<<if $HEALTH < 1>>

The assailants rescue a wounded Aaliya and take you on board as a companion. You go on to become a fairly successful gang member -- that is until turf wars over control of Lyari end with 12 bullets in your gut causing massive blood loss.

You are dead.

<<endif>>

[[not dead option 1 of passage still showing/clickable]]
[[not dead option 2 of passage still showing/clickable]]

Please help!

Comments

  • OK, let's get the first problem out the way and that's < , >, <= and >= (as used in the IF statement).  In Twine I've found that they don't work and you have to do it differently.  So:

    < becomes lt (Less Than)
    > becomes gt (Greater Than)
    <= becomes lte (Less Than or Equal)
    >= becomes gte (Greater Than or Equal)
    = becomes eq (EQual)

    In SET it's not a problem and you can happily use &lt;&lt;set $HEALTH = 100&gt;&gt; and it will work, but you can't use &lt;&lt;if $HEALTH &lt; 1&gt;&gt; and you need to use &lt;&lt;if $HEALTH lt 1&gt;&gt; (I've been using Twine for several months now and I still make this mistake occasionally).

    Anyway, the code you'd need is...

    <<set $HEALTH = $HEALTH - 40>>
    <<if $HEALTH gte 1>>
    Whatever happens when player is still alive.
    <<else>>
    Whatever happens when player is dead.
    <<endif>>
    Don't forget there's also <<ELSEIF>> as well if you wanted a kind of in between point so you could have...

    <<set $HEALTH = $HEALTH - 40>>
    <<if $HEALTH gt 10>>
    Whatever happens when player is still alive and relatively OK.
    <<elseif $HEALTH gt 0 and $HEALTH lte 10>>
    Something that happens if the player is critically wounded.
    <<else>>
    Whatever happens when player is dead.
    <<endif>>
    If you have a look at http://2yu.co/sewb you'll find a game called Super Epic Warrior Battle which is something I've been working on for a little bit, and if you play the first battle, watch out for when your enemy gets below 6 HP because then you'll be able to try a fatality.  That's basically doing the above code that uses &lt;&lt;elseif&gt;&gt;.

    Hope that's helped.
  • AntonMuerte wrote:

    OK, let's get the first problem out the way and that's < , >, <= and >= (as used in the IF statement).  In Twine I've found that they don't work and you have to do it differently.

    This is only true for version 1.3.5 - in 1.4 they are the intended operators and function correctly (but I confess that the visual camouflage of the < and > symbols amid the macro's closing >> may make people prefer the original text versions).

    (In detail: 1.3.5 had a bug where the ">" symbol couldn't be used anywhere inside macros, thus necessitating the use of "gt" - however, the "<" symbol did not have this issue.)

    AntonMuerte wrote:

    = becomes eq (EQual)

    This is flat-out wrong - == becomes "eq", and = becomes "to". It's due to this incredibly common UI disaster that I do not endorse "eq" or "=" at all, and encourage "is" and "to" instead.


    ...

    But your main point is correct: the top post need only add an <<else>> macro to produce their desired effect:

    You are dead.

    <<else>>
    [[not dead option 1 of passage still showing/clickable]]
    [[not dead option 2 of passage still showing/clickable]]
    <<endif>>
Sign In or Register to comment.