- Feb 22, 2022
- 43
- 42
Hi,
I am currently creating a script that has the following code for an exitButton inside a widget.
The idea here is that I can call <<widget "passage1">> and then go to passage1 when the exit button is pressed. If I just say <<widget>> it should return to the previous passage. That does not work, however.
The whole thing (and lots of other code) is wrapped in <<done>> and <<script>>.
My question is: Can I even use $args[0] to affect javascript code? And is the method of calling the previousPassage correct or should I use previous()?
Thanks!
I am currently creating a script that has the following code for an exitButton inside a widget.
Code:
exitButton.addEventListener('click', () => {
console.log('Exiting the game');
saveState();
// Check if a passage name was provided as an argument
const passageName = $args[0] || State.variables.previousPassage;
if (passageName) {
// Navigate to the specified passage or the previous passage
Engine.play('passageName');
}
});
The whole thing (and lots of other code) is wrapped in <<done>> and <<script>>.
My question is: Can I even use $args[0] to affect javascript code? And is the method of calling the previousPassage correct or should I use previous()?
Thanks!
Last edited: