Hi-despite playing around with Twine 1.0, I'm still very much a beginner-I've tried making a game with a simple yes/no variable, with a latter link not appearing if the variable remains"no" (in this case, picking up an object)
but for some reason, the link to that passage either always shows up, or half the passage flat out disappears. I'm currently using sugarcube-any advice?
Comments
<<silently>>
<<set $cross="no">>
<<endsilently>>
and here's the second:
<<set $cross = "yes">>
and here's the last bit:
<<if $cross= "yes">> The sight of the cross repeals them
<<else>>you're powerless to resist there charms <<endif>>
I'm thinking about switching over to Harlowe -it seems a bit easier
So you would want:
Also remember you can use booleans like true and false. Brush up on:
http://www.motoslave.net/sugarcube/1/docs/macros.html#macros-set
I just use 1 and 0 for these types of variables. I find it simpler than using strings.
Also, bear in mind that you are using an else statement, so there's technically no need to set a false condition, since <<else>> assumes falsehood if the true condition is not met. You could simply say in the second passage:
And then in the other say:
All that said, it's still recommended to initialise $cross to false at story start in the StoryInit special passage. You just do not need to set it to false in the actual story once you've done that, since we assume that your protagonist does not start the game with a cross.
In Twine (and Javascript) a single equals sign '=' means assignment where as a double equals sign '==' is used to compare. So what is happening in your <<if>> macro is that you are assigning the value of 1 to your $cross variable and then testing if that assignment was true.
For this reason I suggest you use the words to and is instead of a single or double equals sign. Your example re-written:
note: you don't need to use the <<silently>> macro in your first passage, <<set>> macros don't output anything expect any new-lines you add yourself, which you can remove using a backslash.
If you want to keep using equal signs then your example would look like the following:
But my second suggestion is still right.
In the example given, the <<set $cross to "no">> is not doing anything at all, as <<else>> will assume anything is false that isn't explicitly defined.
You cannot write <<set $crossto 1>>, because you end up with the $crossto variable. It's still code, and the white space makes a considerable difference.
I put it out there because it's possible (without me knowing more), that Twine does some funky conversion of "=" to "to", resulting in mangled variables. (EDIT: Though I tested it just then and this is not the case for $cross=, though $crossto produces an error indicating it wants the white space.)
It's always best to directly follow the story's example syntax, which includes white space, so I think that's still worth commenting on.
The <<set>> macro:
It is a good idea to place a single space between the variable name and the assignment symbol (either = or to), and between the assignment symbol and the value:
The <<if>> macro:
It is a good idea to place a single space between the left part of a condition and the comparison symbol, and between the comparison symbol and the right part: