Hello everyone!
I have a passage that I have to modify dependind on the player choices. Currently I'm doing it using <<addclass>> and <<removeclass>> to add a css class with "display: none" on it to the passage divs I want to show or hide. So far i works perfectly like this:
<div id="scnAwakening_choices">\
<div class="choice charText playerText">\
<ul>\
<li><<click "I must remain calm">>\
<<addclass "#scnAwakening_choices" "hidden">>\
<<removeclass "#scnAwakening_calm" "hidden">>\
<<set $events.calmAwakening to true>>\
<</click>></li>
<li><<click "Let me out!!">>\
<<addclass "#scnAwakening_choices" "hidden">>\
<<removeclass "#scnAwakening_notCalm" "hidden">>\
<<set $events.calmAwakening to false>>\
<</click>></li>
</ul>\
</div>
</div>\
<div id="scnAwakening_calm" class="hidden">\
(Some calmed text here)
[[Continue...|scnAwakening_calm]]
</div>\
<div id="scnAwakening_notCalm" class="hidden">\
(Some text here)
[[Continue...|scnAwakening_notCalm]]
</div>\
The problem is that if I reload the game or visit another passage from a link in the StoryCaption and return to this one, the passage goes back to its initial state, before reasigning the "hidden" class. So I decided to use a variable and a bit more of code to track in witch "state" the passage is (wich divs are visible or hidden) like this:
<<switch $state.scnAwakening>>
<<case 1>>
<<addclass "#scnAwakening_choices" "hidden">>\
<<removeclass "#scnAwakening_calm" "hidden">>\
<<addclass "#scnAwakening_notCalm" "hidden">>
<<case 2>>
<<addclass "#scnAwakening_choices" "hidden">>
<<addclass "#scnAwakening_calm" "hidden">>
<<removeclass "#scnAwakening_notCalm" "hidden">>
<</switch>>
(The value of $state.scnAwakening is update inside the <<click>> macros)
The problem here is that when this code is loaded, I receive an error saying that none of the <<addclass>> or <<removeclass>> from that part of the code can find any element matching the selector, despite they were found the first time. I've tried using this code both at the begining and at the end of the passage, with the same result.
Anybody knows what I'm doing wrong? (probably a lot of things... ) Thanks!