Set Variable: Difference between revisions
m
Replace with Image templates
-u ndefined- (talk | contribs) m (Substitute any instances of ` to <code> tags) |
-u ndefined- (talk | contribs) m (Replace with Image templates) |
||
Line 1: | Line 1: | ||
{{Block | {{Block | ||
|image= | |image=Set_Variable_number.png | ||
|type=s | |type=s | ||
|folder=Variables | |folder=Variables | ||
Line 12: | Line 12: | ||
If you were to set another value to a variable, it will overwrite the previous value of that variable. | If you were to set another value to a variable, it will overwrite the previous value of that variable. | ||
You can get/output the value from a variable with the same name and | 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.}} | |||
== Global variables == | == Global variables == | ||
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.}} | |||
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 30: | 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.}} | |||
== Saved variables == | == Saved variables == | ||
Line 37: | 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.}} | |||
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. |