Forum Discussion
zamond1
2 days agoCommunity Member
Why hasn't Articulate prioritized simple adding of multiple variables at once?
For instance, if I had the following variables (user-inputted values):
blueberries = 6
strawberries = 7
bananas = 3
apples = 8
honeydew = 7
mango = 5
pears = 6
oranges = 9
waterme...
- 2 days ago
You are correct about Storyline not having a single trigger that can sum multiple numbers.
However, you don't have to repeat the set of triggers that calculate the sum every time one of your input variables changes. Instead, you could do this:
Create a "calculation" layer.
- Don't add any content to the layer.
- Set the Slide Layer Properties to "Reset to initial state."
- Set the timeline very short (e.g., 0.25 sec).
- Create a trigger to reset your "totalFruit" variable to 0 when the timeline starts on the layer.
- Create the triggers that add each separate "fruit" variable to the "totalFruit" variable when the timeline starts on the layer.
- Create a trigger that hides the layer when the timeline of the layer ends.
Back on the base, add triggers that shows the "calculation" layer when each "fruit" variable changes. So if you have 9 fruit values, there would be 9 triggers showing the layer.
Yes, it's still more complicated than if there were a "sum" trigger. But at least this method is easier than repeating the calculation triggers whenever any input variables changes.
Another option: run JavaScript for the calculation.
PhilMayor
20 hours agoSuper Hero
Or as Judy suggest do it in JS
// Get access to Storyline variables
var player = GetPlayer();
// Get values from Storyline
var blueberries = player.GetVar("blueberries");
var strawberries = player.GetVar("strawberries");
var bananas = player.GetVar("bananas");
var apples = player.GetVar("apples");
var honeydew = player.GetVar("honeydew");
var mango = player.GetVar("mango");
var pears = player.GetVar("pears");
var oranges = player.GetVar("oranges");
var watermelon = player.GetVar("watermelon");
// Calculate the total
var total = blueberries + strawberries + bananas + apples +
honeydew + mango + pears + oranges + watermelon;
// Push result back to Storyline variable
player.SetVar("totalFruitCost", total);
Related Content
- 10 months ago
- 11 months ago