I'm using sugercube 2.6.2 (and I've tried it in SugarCube 1.0.34 as well) and I cant get any of my if statements or set commands to work. I believe I am doing everything correct but here is a sample of what I'm doing:
In one of my pages I want to set gold to 200
<<set $gold to 200>>
where in a StoryCaption sheet I have:
<<set
$gold to 0;
>>
Gold <<print $gold>>
This shows Gold 0 in my game's side bar but the command for set gold to 200 doesn't change it to 200 and I still see Gold 0.
Also when I try to use if statements for my variables it doesn't work:
<<if $gold is 200>>
Enter store.
<</if>>
Go home.
All I see in my test is: Go home
Do I need to add a tag to the page or make some indication for the commands to work? I'm still new to this so I could really use the help!
Comments
If you want to set gold to 0 at start of game, write in your StoryInit passage instead:
<<set $gold to 0>>
The only thing that should be in StoryCaption is:
Gold <<print $gold>>
For your if statement, you will need to use an <<else>> direction otherwise you will display two passages at once. Also, make sure that the link names directly match the passages. Eg with Enter store. you need to include the full stop in the passage name too.
<<if $gold is 200>>Enter store.<<else>>Go home.<</if>>
Additionally, you could print the value of gold like so: The naked variable formatter allows you to simply reference story variables to print them. You'll still need the <<print>> or <<=>> macros for more complicated things, like expressions.
@Claretta As to the home link, they may want it to always display, in which case what they have currently is correct. Personally, I assumed that they're making a list of possible actions, with going home always being available.