Tabulating score dynamically using add/subtract and variables

Jan 16, 2018

I'm trying to build a gameified interaction in Storyline and I'm running into trouble.

Here's how it works - you have a limited number of tokens that you need to "spend" across multiple categories, with each category having an option for 1, 2 or 3 tokens. This is designed to be difficult, with users likely having to change their selection multiple times in order to make this work within their budget. 

I've been using button sets to ensure only one choice is selected per category, and playing around with variables to tally up total tokens used. Where I get stuck is how to manage when users can change their selection without using some type of "reset" option. Adding tokens used to a variable is easy, however when a user changes their selection, it adds the value of the new choice to the variable, and does not subtract the first choice from the total.

Is there a way to do this without a reset function?

Thanks so much!

9 Replies
Walt Hamilton

Don't add or subtract, recalculate.

Every time a change is made, recalculate from scratch for that category, and store it in a variable for that category. Every time a change is made, calculate that variable, and add it to the other categories to get a total..

For example, learner changes a choice in category 1:

Change variable Category1SubTotal Assign (=) 1 on condition (if) choice1 state = Selected

Change Category1SubTotal = 3 if choice2 state = Selected

Change Category1SubTotal = 1 if choice3 state = Selected

Change Total = 0

Change Total Add Category1SubTotal

Change Total Add Category2SubTotal

Change Total Add Category3SubTotal

This is not only the easiest way to keep it sorted out, it uses the fewest triggers, and is virtually the only practical method of ensuring that your total is accurate.

 

Stefanie Lamanna

Hi Walt,

Thanks so much for this.. I've been playing around with what you've suggested and I'm still getting stuck on the final total. The way I had originally envisioned this slide is that I'd have a running total that would change dynamically as a user interacts with the game. I'm still struggling with the final tally as how I'm doing it now, the total value is becoming an accumulation of every choice the user has made.

Your method of adjusting the variable on the subcategories seems to function perfectly, but how do I get the final total to recalculate with each change? Essentially the total is the combined value of the subcategories.. Do you have a suggestion for how I might set it to recalculate with each change, without having to use a "calculate" or "reset" button? 

Thanks again for your help - I enjoy seeing how far I can push this program! 

Walt Hamilton

Try this.

I use Oval 4 to save creating a lot of extra triggers. Without it, you have to create all the triggers that are attached to it, and set them to fire when Category1 changes, AND another identical set to fire when category2 changes, AND a 3rd set to fire when category 3 changes.

Using the oval is like what programmers call a subroutine. You only have to create the triggers once, and you have them all work whenever the object becomes visible. A certain amount of time passes to allow it to do its thing, then it becomes invisible.

There is no way to know when it becomes visible, so I use when its timeline starts. It doesn't have the option of when its timeline reaches a certain point, so I create an artificial timeline with an animation, and use the end of the animation to trigger when it hides.

CT  Learning

Hey So I thought about doing all this variable flipping stuff.  But then I realized I can just create a results slide, check off all the questions from all the separate quizzes I want to be added to the score, and then storyline creates a score points variable that I cna just use in a dynamic text box.  Don't need to do any nonsense. Don't even need to visit the results slide, just create it and stick it off to the side somewhere.  If you delete it though your variable disappears too.  And lets not forget about dumb bugs that will uncheck all the questions associated with a results slide, everytime you create a new results slide.

Tess Groot

Hi Walt,

I got a similar problem and I used the triggers in your first reaction and they all worked perfectly. I got a few categories with all 2 to 3 choiches. Only I want the variable Total (of all the categories) to make it change the state of an object on the next slide. I think I'm using the right trigger:

Change state of Object1 to Changed, when Total changes, If Total is Greater than or equal to 2.00

But nothing is happening, and I can't figure out why. Do you know how I could fix this? 

This discussion is closed. You can start a new discussion or contact Articulate Support.