As a note, I’m new to Twine. I’ve spent the last two hours trying to figure this out. I’ve looked at a Beginner’s Guide to Twine 2.1, the Twine Cookbook, and read about variables, but they haven’t given me a clue to fix the issue I’ve been having.
I want to make the sanity meter decrease from 100 to 95 based on a choice. This is how I wrote it to show the sanity variable and the one written in JavaScript in the first section, and how it’s shown on screen on the player profile in the second section:
<<set $sanity to 100>>
State.variables["Sanity"] = 100
Sanity: $sanity %
I’ve tried putting both variations of these in the section after you make the choice, but it didn’t change the 100 after selecting the particular choice:
<<set $sanity -=5>>
<<set $sanity to $sanity -=5>>
Next, I’ve tried putting it within the choice itself, but it doesn’t work for either variation, not even moving from the top to the bottom of this did anything to change it:
<div class="choice">[[Go out there and stop them]]
<<set $sanity to $sanity -=5>></div>
Then I tried this, but I keep getting a state error, or ‘<<‘ is an unexpected token error, even though it’s Sugarcube:
<div class="choice">[[Go out there and stop them][<<$sanity to $sanity -=5>>]]</div>
<div class="choice">[[Go out there and stop them][State.set $sanity -=5]]</div>
Lastly, I tried links like the one from the Twine Cookbook, but it didn’t work at all either:
<div class="choice">
<<link "Go out there and stop them">>
<<set $sanity - 5>>
<<goto "Go out there and stop them">>
<</link>></div>
I’m at the end of my rope here. I’ve scoured online to find the solution to this specific problem with making a set number decrease, but I can’t find it. Please, if anyone can tell me, what am I doing wrong? Is there a solution to change the set 100 variable to decrease? Is it supposed to be a temporary variable instead of a set one?