Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Variables in Sugarcube 2.11.0

$
0
0
Not so much a question, but I'd like to try and understand variables. I know there's documentation out there and I will read it, but this is quite specific.

I know how a simple variable works, such as when checking for true. Thus:
<<if $hasKey>>The door unlocks<<else>>The door is locked.<</if>>
This checks if the variable $hasKey has been set to true, and if so unlocks the door. If not, it doesn't.

But.

Take this for instance, which is a script I have for opening a door with a keycode which the player has to type in. In a passage prior to this I set the variable $knowsCode to true and then say:
<<if $takenDrug>><<textbox "$keycode" "" "resultgood">>
<<else>>
<<textbox "$keycode" "" "resultbad">><</if>>
This works*, but I don't understand the purpose of the variable $keycode. This is just the name I gave it, because I understand I must, but I'm not referencing it anywhere else so what's its purpose here?

*Because they don't need to enter a specific number. Instead they're able to 'guess' the number because they've taken something which bring them incredible good fortune, so any input would suffice.


Viewing all articles
Browse latest Browse all 1844

Trending Articles