Short version:
I'm trying to use a <<set>> macro inside a <<link>> block for updating the value of a pre-existing variable, but its value is not updated until I advance to the next passage. How can I force the variable to update right after clicking the link?
Long version:
I'm trying to make a somewhat interactive passage where you can talk with another character, choosing different options and such. For this I'm using lists of <<link>> macros with <<addclass>> and <<removeclass>> for hidding or showing different <div> blocks so the passage content updates as the conversation goes on. This works fine, but of course if the player saves and load the game in the mid of the conversation the passage goes back to its first state. So I thought of using a variable to track wich options where chosen in each part of the conversation and the check it in PassageDone to update the passage.
In the game passage:
<div id="000a_choices" class="choices">\
<ul>\
<li><<link "Choice 1">>\
<<set $state_000a to 1>>\
<<addclass "#000a_choices" "hidden">>\
<<removeclass "#000a_choice1" "hidden">>\
<</link>></li>
<li><<link "Choice 2">>\
<<set $state_000a to 2>>\
<<addclass "#000a_choices" "hidden">>\
<<removeclass "#000a_choice2" "hidden">>\
<</link>></li>
</ul>\
</div>\
<div id="000a_choice1" class="hidden">\
<p>This is the Choice 1</p>
[[Next1]]
</div>\
<div id="000a_choice2" class="hidden">\
<p>This is the Choice 2</p>
[[Next2]]
</div>\
In PassageDone:
<<switch passage()>>
<<case "000a">>
<<switch $state_000a>>
<<case 1>>
<<addclass "#000a_choices" "hidden">>\
<<removeclass "#000a_choice1" "hidden">>\
<<case 2>>
<<addclass "#000a_choices" "hidden">>\
<<removeclass "#000a_choice2" "hidden">>\
<</switch>>
<</switch>>
The hidding/showing part in the game passage works fine, the problem is when saving after chosing an option the $state_000a variable is not properly saved and still shows its previous value, so when reloading the game PasageDone doesn't work. However, when going to the Next passage, the variable is properly updated.
Does anyone know how to make <<set>> update the value of the variable properly? Thanks!