Reset multiple variables to default values

Jul 31, 2014

Is there any shortcut for reseting many variable to their default values? I'm creating a scenario based training in which I have about 20 variables tracking user progress. If they choose to restart the training I need to reset all of the variables. Can that be done with a single trigger or javascript versus adding 20 individual triggers to my Restart button? Thank you!

39 Replies
Yvette Healey

Ashley...I think the reason I initially looked into the JavaScript code is because I was having trouble with multiple individual triggers to reset 11 variables to true when a button is pushed. In other words, won't only the FIRST variable in the 11 triggers reset once the button is clicked? Or will ALL 11 triggers run to reset all 11 variables to 'false' before the trigger "to to main menu" runs?

Ashley Terwilliger-Pollard

Hi Yvette, 

You'd have to have a trigger for each variable and all those would appear before the jump to main menu trigger to ensure they were executed in time. Again - a lot of triggers! So the Javascript may be the option that you're looking for...but the code can be tricky. One errant comma and the whole thing is off. 

Leslie McKerchie

Hey Gary! 

Looks like all of your options have been shared in this thread.

  • Triggers for each variable
  • JavaScript shared by community

Just be sure that the triggers have time to execute before you jump to the beginning of your course, or they could execute when the timeline starts on that first slide.

Dwayne Schamp

I'm thinking it would be a great idea to add the resetvars option to the action list. SL already has a complete list of user created vars, their type, default values, etc. so creating the code to run through the list and reset them based on those default options is quite easy with a recursive function call. 

having to create 10s of triggers or create a javascript solution is a time wasting issue.