3 buttons effecting one variable

Jun 15, 2020

Hello,

I am making a slide in a course that displays how a vehicle's accessories (headlights, windshield wipers, heated seats) can effect the vehicle's range per charge (measured by mileage). I have a custom toggle button that represents each accessory. I want each button to effect the mileage both independently and together.

I've attached some pictures for reference. For instance, headlights.jpg shows the mileage being decreased by 2, wipers by 2, and heated seats by 10. I figured out how to make each one work independently by directing the user to the subslides vie "show layer trigger". However, I can't figure out how to make them all work with one another. Meaning, if the user were to toggle on two accessories at a time. Any insight on this would be a huge help.

Thank you!

4 Replies
Walt Hamilton

Set lights, wipers, and seats variables to T/F variables. That way when they are clicked, they can flip from one value to another, and save you about a dozen triggers each. (Probably you already did this, but all I have to go on is pictures, so I don't really know what is happening.)

When user clicks headlights, run these triggers:

toggle variable Headlights

set efficiency to 1

subtract .02 from efficiency if headlights = True

subtract .02 from efficiency if wipers = True

subtract .02 from efficiency if seats = True

multiply range by efficiency

The secret is that is is magnitudes simpler to calculate from scratch every time a change happens than it is to try to keep track of everything and add or subtract depending on what changed how. It's confusing even to try to describe it.

C C

Thanks, for the speedy response. What you suggested worked for what I asked for, but is there a way to limit how many times the user can keep adding or subtracting to the value? As of right now, the user can keep clicking the toggles to add/subtract indefinitely. The client requested the value only go as high as 300 (max efficiency) or as low as 286 (range if all three accessories are selected.) I also seem to be getting some small white text on my buttons that I can't seem to get rid of. I've attached a copy of my storyline file for clarification. 

Walt Hamilton

Craig,

Let me introduce to some of the hidden magic of SL that will solve most of your problems. First change the toggle buttons. give them each a "Selected" state. I did this by copying your "down" State, Naming it "Selected", and deleting the Down State (I mention this so you and everyone reading this will be reminded to got here: https://articulate.com/support/contact/feature-request and request a feature to rename states.) Naming a state "Selected" invokes powerful SL magic. If you click it, it toggles between Normal and Selected automatically: Click - On. Click again - Off, etc. So that lets you get rid of a lot of extra shapes and triggers.

As a special bonus, you can't keep clicking it and adding or subtracting. If it is off, and you click it it is on. If it is on, and you click it, it isn't on twice. I like to say, don't add and subtract every time. Start from scratch, and calculate everything, and you won't have to remember anything; you just take it as it is, and use it to calculate.

In practical terms, that means every time the learner clicks a toggle, you reset the range to its max, reset efficiency to its max (100% or 1), Then cycle the things that lower efficiency(lights, seats, wipers), and for each one that is on subtract 2% from efficiency. multiply efficiency times range, and Bob's your uncle.

FYI: If you were to do this in your head, you would think "turning on lights, range is dropping from what it already is.", So this way is not mentally intuitive, but for the computer, it is a lot faster, and easier because you only keep track of the important things, and what the range was before you made this change isn't important to figuring out what it is now.

Slide 1 will explain the white text.

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