The true/false variable works just like it sounds: values can either be true or false. Some examples of where you'd use a true/false variable are:
- Scene or slide completion: Adjust variable Section1 to true when user completes Slide 10.
- Compliance acknowledgement: Adjust variable Agree to True when user clicks Submit button.
Let's take a look at a simple example using two buttons.
If you're following along, I'm working in TrueFalse_START.story.
Step 1: Create a New Project Variable
We have two buttons on the slide, but we only need a single variable to evaluate.
- In the Triggers panel, click Manage project variables to create a new variable
- Click the Create a new variable icon
- Name your variable: Agree
- Set the variable type to True/False
- Set the value to False
Step 2: Insert a Reference to the Variable
This is not necessary, but it's a big help when working with variables. By inserting a reference to the variable, we can verify the variable is working the way we expect it to work. We'll delete the reference at the end of the project, but keep the reference for testing both the variable and the buttons.
- Insert a text box on the slide by going to Insert > Text > Text Box and clicking once on your slide
- Go back to the Insert tab this time go to Text > Reference. This brings up your project variables. There's only one variable so it will automatically be selected.
- Click OK to close the window and insert the variable reference.
- With the variable reference selected, increase its font size to something large, like 36
Let's preview our work. Click F12 or Preview to preview the slide.
Nothing much happens, but we can see the variable reference returned a false message. That's the default value we assigned when we created the variable. Next, we'll add some triggers to our buttons.
Step 3: Assign Button Triggers to Adjust the Variable
At this point, you've created the True/False variable, but it's not useful until we assign a trigger to evaluate it.
In the Trigger panel, click the Create a new trigger icon
- Action: select Adjust variable
- Variable: select Agree
- Operator: keep the current setting
- Value: change to Value and then select True
- When: keep current setting
- Object: keep current setting
- Click OK
Now that our first True trigger is set, we can copy and paste it for the False button.
- In the Triggers panel, select the trigger you just created
- Click the Copy selected trigger icon to copy the trigger
- On your slide, click the False button once to select it
- Return to the triggers panel and click the Paste the copied trigger to the selected object icon. This pastes the True button's triggers to the False button. You now only need to modify the False button's triggers
- For the False button's trigger, select the true value and select False from the menu
Preview your project and test your buttons.