Tutorial - Getting and Setting Part Properties
/
Tutorial - Getting and setting part properties
instructions
Instructions
In this tutorial, we'll set up a simple flowchart that checks the state of a chip pan and turns a smoke alarm on if the chip pan is on fire.
- From the Parts pane drag on a button then right click and using the properties window select + then navigate to common on school croc images house (inside) pan on onto your scene. Next you need a smoke alarm animation the animation comes from outputs, drag on an animation part then right click, properties + button and navigate to common the animations and smoke alarm.
- From the Parts pane, add a start flowchart part.
- We need to check the value of the pan button (that is, whether it is on or off) and then set the smoke alarm animation so that it is on. Drag on a get property part from the Parts pane inputs and outputs so that it connects directly with the start part.
- Associate the get property part to the pan using the target tool. Now click on 'Property' to select the property of the pan button whose value will be stored in the variable x. Select 'Value'.
- The 'value' property of a button is of Boolean type, so it is TRUE when the button is pressed and FALSE when it is not pressed. So to test whether the button is pressed (and the pan is on fire), drag on a test variable part from decisions and connect it directly to the set variable part.
- We want to see whether x is TRUE, so click on the '0' on the test variable part and enter 'TRUE' instead. (Make sure you use upper case letters, or the flowchart will not run as expected.)
- If x is not TRUE, we need to keep checking the state of the button until it is pressed, so connect the 'N' output of the test variable part to the input of the get property part.
- If x is TRUE, then we want to set the fire alarm animation so that the alarm is on. Drag on a call action part from inputs and outputs and connect it directly to the 'Y' output of the test variable part.
- Associate the call action part to the smoke alarm animation and, selection the animation "Smoke alarm on" from its action menu.
- Add a delay part from the Parts pane and connect it directly to the set property part.
- Add a call action part to the scene and connect it directly to the delay part. Use it to change back to the "smoke alarm off" animation.
- Add a stop part and connect it directly to the last set property part.
- Now run the flowchart. Click on the pan to change its state. If the pan is on fire, the smoke alarm sounds for five seconds and then goes off.