Forum Discussion
SergeyAvseenko
10 months agoCommunity Member
Change the status of CheckBox on restart based on localStorage
Hello!
There is a task to make sure that the progress between sessions is saved in localStorage. Specifically, the CheckBox states (Normal/Selected).
1. Using JavaScript, I made it so that when ...
SamHill
9 months agoSuper Hero
Hi there,
if you want to update variables in storyline through JavaScript, you must do it like this:
var red = localStorage.getItem("Red")
var green = localStorage.getItem("Green")
var blue = localStorage.getItem("Blue");
// get a reference to the player
var $player = GetPlayer();
// set the storyline variable
$player.SetVar('globalRed', red+"" === "true");
$player.SetVar('globalGreen', green+"" === "true");
$player.SetVar('globalBlue', blue+"" === "true");
You can then use a trigger in Storyline to update whatever you need:
I'm attaching a working example of how you could do this with your file. I'm using the the variables in the Storyline to provide the initial trigger only. The rest of the functions just work on the localStorage data and the state of the checkboxes.