Howdy, Stranger!

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

When life = 0, display message?

When the $health variable equals 0 I want it to go to another passage saying you died or something.  How do I do that?

Comments

  • You would put this at the end of all your passages (or at least the ones where you can die.:

    <<if $health eq "0">>
    <<goto "Death">>
    <<endif>>

    In order for the <<goto>> to work you must make a new script passage and paste this into it:
    version.extensions.timedgotoMacro={major:1,minor:2,revision:0};
    macros["goto"]=macros.timedgoto={timer:null,handler:function(a,b,c,d){function cssTimeUnit(s){if(typeof s=="string"){if(s.slice(-2).toLowerCase()=="ms"){return +(s.slice(0,-2))||0
    }else{if(s.slice(-1).toLowerCase()=="s"){return +(s.slice(0,-1))*1000||0
    }}}throwError(a,s+" isn't a CSS time unit");return 0}var t,d,m,s;
    t=c[c.length-1];d=d.fullArgs();m=0;if(b!="goto"){d=d.slice(0,d.lastIndexOf(t));
    m=cssTimeUnit(t)}d=eval(Wikifier.parse(d));if(d+""&amp;&amp;state&amp;&amp;state.init){if(macros["goto"].timer){clearTimeout(macros["goto"].timer)
    }s=state.history[0].passage.title;macros["goto"].timer=setTimeout(function(){if(state.history[0].passage.title==s){state.display(d,a)
    }},m)}}};
    "Death" can be replaced with whatever your death screen passage is called.
  • If you don't need to literally "go to another Passage" you can accomplish what you need without needing to add a script, just using built-in Twine functionality, by displaying the text of another passage inside your current passage. Just use the "display" macro:

    <<if $health eq "0">>
    <<display "Death">>
    <<endif>>
  • .. and (adding to loopernow's response) you might want to display "death" instead of the rest of the passage- so start each passage with:
    <<if $health eq "0">>
    <<display "Death">>
    <<else>>

    (insert the rest of your passage here)


    <<endif>>
Sign In or Register to comment.