Forum Discussion
Reset multiple variables to default values
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
Hi Sheetal!
This thread is a bit dated, but you can accomplish this set-up.
Check out the attached file.
- YvetteHealeyCommunity Member
GREAT thread! I have incorporated JavaScript to reset a large number of variables, and it's working great. The PROBLEM is that, after all variables are reset to a value of FALSE (after one particular value having been true), it appears as though a user going through the course subsequent times, triggering Variable 2 to be "true" on the second go-round, that the variable 2 is NOT marked true by the same trigger that successfully made Variable 1 "true" the first time through the course. In other words:
1) Initial course run through, Variable 1 triggered from "False" (default) to "True"
2) Element later in course successfully recognizes Variable 1 as "True" and behaves properly!
3) User clicks "return to menu", which executes JavaScript to reset all variables to "False" (regardless of which variable the user clicks).
4) User runs through course a second time and Variable 2 is triggered from "False" (default and result of JavaScript execution during Course Round 1) to "True".
5) But when user gets to element later in course (as in 2) above), the variable is NOT recognized as true. In fact, ALL variables are false, regardless of which variable was set to True earlier.
What did I do wrong? Is there some software issue of which I am not aware? I DID test this in a live LMS Environment (not just on course preview mode in Storyline 2).
Thank you for any help! I have to launch this course in 2 days, and this is my last little (?) glitch! The other elements of the course are working beautifully!
Hi Yvette,
I'm not equipped to assist with the Javascript elements, but you may want to post this course or the code so that the community could weigh in to assist.
- YvetteHealeyCommunity Member
Thanks, Ashley! I am adding the course here as an attachment (formatted for Web Delivery). As an aside, should I try using numerous triggers in Storyline (no Javascript) to reset the variables instead of JavaScript?
Testers: Please begin the course by clicking on the "First Floor" caption. Mouse over and choose a section and remember your color. Click on that section and view the evacuation route. Then hit the "Proceed to Outdoor Meeting Location" button that pops up at the end of the route. There is a brief layer or two of info, and then you get to the layer that shows you the color-coded outdoor location signs. Remember WHERE your sign is. On the next slide, click the sign that matches the color whose route you just viewed. On the "correct" screen, click the "Main Menu" button and try a SECOND route of a different color. Note how, after viewing the route for THAT second department/color, clicking on the correct outdoor sign color does NOT yield a correct screen :-(
Thank you for any help!
Hi Yvette,
It sounds like something you could set up with regular triggers and variables - but I'd hate for you to go through that if it's just a line of code or something off in the javascript set up. Hopefully folks in our community are able to weigh in here and if you don't hear anything by tomorrow it may be worth starting a new thread with the Javascript element in the title so that they're able to spot it easily. :-)
- YvetteHealeyCommunity Member
GREAT idea! Let me try setting up a new thread now in addition to having replied to this older one. If all else fails within the next 24 hours, I'll try using the built-in variable reset to see if that works. Thank you!
- YvetteHealeyCommunity Member
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?
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.
- YvetteHealeyCommunity Member
Indeed! If I could be assured (by specifying order) that each variable could be reset to False in the split second before the "Jump to slide" trigger, I'd feel better. Isn't that theoretically what's supposed to happen?
Theoretically yes :) You can see the information here in regards to the order in which triggers are executed. So from top down, within each of the sections (player, slide, object).
Related Content
- 12 months ago
- 12 months ago
- 12 months ago
- 12 months ago