Var is: Difference between revisions
(updates from Blockument) |
(Marked this version for translation) |
||
Line 2: | Line 2: | ||
<translate> | <translate> | ||
<!--T:4--> | |||
<section begin="image"/>[[File:var_is.png|alt=The Var Is Block|thumb]]<section end="image"/><p id="tooltip">Creates a variable with a specified name.</p> | <section begin="image"/>[[File:var_is.png|alt=The Var Is Block|thumb]]<section end="image"/><p id="tooltip">Creates a variable with a specified name.</p> | ||
==Usage== | ==Usage== <!--T:5--> | ||
<!--T:2--> | <!--T:2--> | ||
Creates a variable (a place to store data) in the agent's context with a specified name. You can rename the variable by selecting the “name” text and typing over it. You can also specify what type of variable using the drop down menu. The variable only exists in the stack of code where it is created. | Creates a variable (a place to store data) in the agent's context with a specified name. You can rename the variable by selecting the “name” text and typing over it. You can also specify what type of variable using the drop down menu. The variable only exists in the stack of code where it is created. | ||
==Syntax== | ==Syntax== <!--T:6--> | ||
<!--T:7--> | |||
Inputs in this block: | Inputs in this block: | ||
#a name for the variable | #a name for the variable | ||
Line 16: | Line 18: | ||
#a value to assign to the variable | #a value to assign to the variable | ||
==Example== | ==Example== <!--T:8--> | ||
<!--T:9--> | |||
[[File:var_is_example.gif|alt=Var Is example gif|thumb]] | [[File:var_is_example.gif|alt=Var Is example gif|thumb]] | ||
[[File:var_is_example.png|alt=Var Is example code|thumb]] | [[File:var_is_example.png|alt=Var Is example code|thumb]] | ||
<!--T:10--> | |||
The code above creates variables to draw stripes across the screen. Since it is useful to keep track of the current y-value to draw each stripe, the ‘var’ block has been used to declare this variable. Since the value of the variable needs to change in order to change the location of the agent drawing the stripes, the [[Special:MyLanguage/Set to|‘set to’]] block is used to set the variable to the current y-value of the agent. | The code above creates variables to draw stripes across the screen. Since it is useful to keep track of the current y-value to draw each stripe, the ‘var’ block has been used to declare this variable. Since the value of the variable needs to change in order to change the location of the agent drawing the stripes, the [[Special:MyLanguage/Set to|‘set to’]] block is used to set the variable to the current y-value of the agent. | ||
Revision as of 19:24, 14 August 2023
Creates a variable with a specified name.
Usage
Creates a variable (a place to store data) in the agent's context with a specified name. You can rename the variable by selecting the “name” text and typing over it. You can also specify what type of variable using the drop down menu. The variable only exists in the stack of code where it is created.
Syntax
Inputs in this block:
- a name for the variable
- a type of variable from the dropdown menu
- a value to assign to the variable
Example
The code above creates variables to draw stripes across the screen. Since it is useful to keep track of the current y-value to draw each stripe, the ‘var’ block has been used to declare this variable. Since the value of the variable needs to change in order to change the location of the agent drawing the stripes, the ‘set to’ block is used to set the variable to the current y-value of the agent.