I have a bunch of things that change in my story if you've died one or more times and are replaying from checkpoints.
I've successfully got it working where it's adding a +1 to the $death_count variable on a loss, but for some reason the If conditional to show certain text isn't working.
For example:
(if: $death_count > 1)[Text here] doesn't produce anything regardless of whether or not there's a death, but weirdly if I set it to the opposite (so if $death_count is less than 1) the text does appear. I'm not quite sure if I'm doing something wrong, or if there's a bug.
Comments
The following code works:
Both the following work for me:
It doesn't work for me. The problem with assigning it an arbitrary value ahead of time is that I have a tally showing how many times a player has died (and this is presented at the checkpoints and also the beginning of the game), so if I assign it a value of 1 then it's just going to show one death inaccurately.
In Twine 1.4x I only incremented $death_count each time the player died and this worked both with the ongoing tally and determining whether or not the additional content appeared. I can't get the same to work in Twine 2.0.
So, I'm not sure what the problem is. How exactly do these checkpoints work?
You can assign it whatever value you like, I only used 1 in the example because it allowed me to do what you described in your original post. eg. Increment a variable by 1 and then check if the current value of the variable was greater than one.
Many years of programming in many different languages has taught me to not rely on the "the variable will have a good default value if you have not defined one" concept as it can change without notice, so I suggest always assign one yourself then you know what its default value will be as some story formats assign default values to undefined variable and some don't.
On a passage where the player dies, I have
(set: $death_count + 1)
At various points in the game I have text that appears if the player has died at least once but which should be invisible otherwise. It works correctly in not showing the text when the player hasn't died yet (or if I change the If conditional to be less than one death instead of greater than) but it doesn't appear when the player has.
Even cutting and pasting the code from greyelf didn't work.
Never code on a hangover, kids.
I think you have mistyped the above because that would result in a "(set:)'s 1st value is the number 1, but should be an assignment operation." error message.
I think you meant to type one of the following:
This works flawlessly inside a passage. However, when I 'display' it remotely from another passage, I get a syntax error, which does not occur with simple GT.