Set Variable: Difference between revisions

m
Fix according to usage
m (Replace with Image templates)
m (Fix according to usage)
Line 14: Line 14:
You can get/output the value from a variable with the same name, type and mode using the [[Get Variable]] block.
You can get/output the value from a variable with the same name, type and mode using the [[Get Variable]] block.


{{Image|File:Set_Variable_inspect_value.png|Storing and retrieving a number.}}
{{Image|Set_Variable_inspect_value.png|Storing and retrieving a number.}}


== Global variables ==
== Global variables ==
Line 20: Line 20:
Let's say you have a script inside a block that sets a variable to 1, and you have a script outside of the block to inspect that variable.
Let's say you have a script inside a block that sets a variable to 1, and you have a script outside of the block to inspect that variable.


{{File:Set_Variable_global_example.png|Set Variable on a script block. On the ground, inspecting its value shows 0 due to locality.}}
{{Image|Set_Variable_global_example.png|Set Variable on a script block. On the ground, inspecting its value shows 0 due to locality.}}


As you can see, we've set the variable to 1, but the Get Variable block outputs 0 as if we never set the variable in the first place.
As you can see, we've set the variable to 1, but the Get Variable block outputs 0 as if we never set the variable in the first place.
Line 31: Line 31:
Note that two variables with the same name with one being a global will not count as the same variables (e.g <code>Number</code> and <code>$Number</code> are not the same).
Note that two variables with the same name with one being a global will not count as the same variables (e.g <code>Number</code> and <code>$Number</code> are not the same).


{{Image|File:Set_Variable_button_global.png|Keypad shown with mode being changed to Global.}}
{{Image|Set_Variable_button_global.png|Keypad shown with mode being changed to Global.}}


== Saved variables ==
== Saved variables ==
Line 38: Line 38:
Saved variables gain a <code>!</code> at the start of their name.
Saved variables gain a <code>!</code> at the start of their name.


{{Image|File:Set_Variable_button_saved.png|Keypad shown with mode being changed to Saved.}}
{{Image|Set_Variable_button_saved.png|Keypad shown with mode being changed to Saved.}}


As the name implies, saved variables persist their value from one game session to the next.
As the name implies, saved variables persist their value from one game session to the next.