[Twine 2.1/Sugarcube 2] Constant if in game. if variable reaches 100 at anytime, game over.

0 votes
asked Dec 29, 2017 by Loliconman (490 points)
edited Dec 29, 2017 by Loliconman

This is a interesting idea I made for a game.

 

I want to make a variable ($Depression) and make it a constant game over possibility.

Example:

<<if $Depression is(ever) gt 100 (and/or) eq 100>>

YOU HAVE BEEN ERASED FROM EXISTENCE!

<<link "BAD END">><<script>>window.close()<</script>><</link>>

 

 

<</if>>

 

Or

<<goto  [[BAD END]]>>

But set up to at anytime it happens, it makes this passage show instead of the desired passage..

 

I dont know how to set up a goto. A cool addition if it only shows the passage for a few seconds then kicks you out of the game

 

I can clarify, but not really too good at making it any simpler

1 Answer

0 votes
answered Dec 30, 2017 by Charlie (9,730 points)
<<if $Depression gte 100>>
  <<goto [[BAD END]]>>
<</if>>

 

commented Dec 30, 2017 by Loliconman (490 points)
is there a way to add this at the start of the game so if at anytime(or other passages), the variable is 100 it performs the script
commented Dec 30, 2017 by Chapel (51,550 points)

Throw it in a passage and name that passage PassageReady, and it'll fire just before each passage is rendered. 

http://www.motoslave.net/sugarcube/2/docs/special-names.html#special-passages

commented Dec 31, 2017 by Loliconman (490 points)

This led to a blank, black passage: used he PassageReady passage

 

<<if $Depression gte 100 >>
  <<goto [[BAD END]]>>
<</if>>

 

and

[YOU HAVE BEEN ERASED FROM EXISTENCE!]

<<link "BAD END 0: Forgotten By All">><<script>>window.close()<</script>><</link>>

commented Dec 31, 2017 by Chapel (51,550 points)

You need to put something in the passage. 

::BAD END
Bad End 0: Forgotten by All... 

[YOU HAVE BEEN ERASED FROM EXISTENCE!]

<<timed 2s>><<run window.close()>><</timed>>

You should probably never assume control of the users browser though, since that's always annoying and always looks like a bug. 

commented Jan 2 by SmuJamesB (2,650 points)
To stop it looking like a bug, you could say the following: "This window will close in 3, 2, 1.."
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...