I am wondering how to go about having n links showing one of them at a time based on user interaction without a page refresh/load.
As an example:
Now this obviously won't work as is due to conditionals being processed on page rendering. I'd like to be able to either show the unlock or the lock links and execute the necessary code based on these actions without having to do a page reload if at all possible.
I am using Twine 2.1.1 and Sugarcube 2.16.0.
As an example:
<<set _doorLocked to false >> <span id="action-text"></span> <<if _doorLocked>> <li><<link "Unlock the Door">> <<replace "#action-text">>You unlock the door.<</replace>> <<set _doorLocked to false>> <</link>> </li> <<else>> <li><<link "Lock the Door">> <<replace "#action-text">>You lock the door shut.<</replace>> <<set _doorLocked to true>> <</link>> </li> <</if>>
Now this obviously won't work as is due to conditionals being processed on page rendering. I'd like to be able to either show the unlock or the lock links and execute the necessary code based on these actions without having to do a page reload if at all possible.
I am using Twine 2.1.1 and Sugarcube 2.16.0.