I am having some issues with the SugarCube 1 Textbox macro:
:access main security
Enter day number (0-100) to view logs. Current day is $time. Click outside to close.
<<textbox "$access" "" "Access Main Security 2" autofocus>>
:Access Main Security 2
<<if $access is "0">>Stuff<<else>>ACCESS DENIED<</if>>
...gives ACCESS DENIED instead of stuff when I enter "0". What am I doing wrong?
I'll have to put the textbox after the if I guess.
Yes. That said, if desired, you could set a temporary variable at the top of "Access Main Security 2", so you don't have to rearrange the order of the <<textbox>> and <<if>>.
SugarCube v2
For example, do something like the following at the top of "Access Main Security 2", before the <<textbox>>:
<<set _hasAccess to $access is "0">>
That will set _hasAccess to true or false depending on the value of $access. Then you simply use that within the <<if>>:
SugarCube v1
Since SugarCube v1 does not have temporary variables, you'll have to use something else. A throwaway property on setup would work for this. For example, do something like the following at the top of "Access Main Security 2", before the <<textbox>>:
<<set setup.hasAccess to $access is "0">>
That will set setup.hasAccess to true or false depending on the value of $access. Then you simply use that within the <<if>>:
Comments
in Access Main Security 2 I repeat <<textbox "$access" "" "Access Main Security 2" autofocus>>
because I want the player to be able to keep entering values. But it resets the variable to blank before the <<if>> macro can kick in.
I'll have to put the textbox after the if I guess.
Yes. That said, if desired, you could set a temporary variable at the top of "Access Main Security 2", so you don't have to rearrange the order of the <<textbox>> and <<if>>.
SugarCube v2
For example, do something like the following at the top of "Access Main Security 2", before the <<textbox>>: That will set _hasAccess to true or false depending on the value of $access. Then you simply use that within the <<if>>:
SugarCube v1
Since SugarCube v1 does not have temporary variables, you'll have to use something else. A throwaway property on setup would work for this. For example, do something like the following at the top of "Access Main Security 2", before the <<textbox>>: That will set setup.hasAccess to true or false depending on the value of $access. Then you simply use that within the <<if>>: