Variables Blocks

Create Variables

{"func":"blockControlScriptVar"}

Script Variables

"Script Variables" allows you to define variables that only exist within a given script or function.

Parameters:

None.

Related Blocks:
{"func":"blockVarPropSet"}

Sample Code:
{"func":"blockControlScriptVar","cat":"var","label":"script variables{varargs:valueScriptVar}","values":[{"type":"wrapper","func":"valueScriptVar","name":"var"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"var"},{"type":"string","value":"0"}],"next":{"func":"blockControlRepeat","values":[{"type":"number","value":"10"}],"containers":[{"func":"blockVarChangeBy","values":[{"type":"string","value":"var"},{"type":"number","value":"1"}]}],"next":{"func":"blockLooksSay","values":[{"type":"wrapper","func":"valueScriptVar","name":"var"},{"type":"string","value":"is 10"}]}}}} Add to my Backpack


Variable Operators

{"func":"blockVarPropSet"}

Set

"Set" allows you to adjust the value of a variable. The first parameter indicates the name of the variable, the second parameter indicates the name of the Actor where the variable resides, and the third parameter indicates the new value for the variable.

Parameters:

Variable: this parameter should be the name of one of your variables.

Actor: this parameter should be the name of the Actor where the variable you want to set resides.

New Value: the value of the specified variable in the specified Actor will be set to this value.

Related Blocks:
{"func":"valueVarPropGet"} ,     {"func":"blockVarSet"} ,     {"func":"blockVarChangeBy"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockVarSet","values":[{"type":"string","value":"NumLives"},{"type":"string","value":"3"}]}} Add to my Backpack


{"func":"valueVarPropGet"}

Property

"Property" returns the specified property of the specified Actor.

Parameters:

Property: this variable is the property you want to access.

Actor: this variable is the name of the Actor whose property you want to access.

Related Blocks:
{"func":"blockVarPropSet"} ,     {"func":"blockVarSet"} ,     {"func":"blockVarChangeBy"}

Sample Code:
{"func":"blockControlIfElse","values":[{"type":"wrapper","func":"valueVarPropGet","values":[{"type":"string","value":"Playing"},{"type":"string","value":"stage"}]}],"containers":[{"func":"blockVarShow","values":[{"type":"string","value":"MyScore"}]},{"func":"blockVarHide","values":[{"type":"string","value":"MyScore"}]}]} Add to my Backpack


{"func":"blockVarSet"}

Set

"Set" allows you to adjust the value of a variable. The first parameter indicates the name of the variable, and the second parameter indicates the new value for the variable.

Parameters:

Variable: this parameter should be the name of one of your variables.

New Value: the value of the specified variable in the specified Actor will be set to this value.

Related Blocks:
{"func":"blockVarPropSet"} ,     {"func":"valueVarPropGet"} ,     {"func":"blockVarChangeBy"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockControlWhile","values":[{"type":"wrapper","func":"valueVar","name":"Playing"}],"containers":[{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpLess","values":[{"type":"wrapper","func":"valueVar","name":"NumLives"},{"type":"string","value":"0"}]}],"containers":[{"func":"blockVarPropSet","values":[{"type":"string","value":"Playing"},{"type":"string","value":"self"},{"type":"string","value":"false"}]}]}]}} Add to my Backpack


{"func":"blockVarChangeBy"}

Change

"Change" allows you to increment the specified variable by the specified amount.

Parameters:

Variable: this parameter should be the name of one of your variables.

Increase: this parameter is the number you want to increase your variable by. Use a negative number to make the number smaller.

Related Blocks:
{"func":"blockVarPropSet"} ,     {"func":"valueVarPropGet"} ,     {"func":"blockVarSet"}

Sample Code:
{"func":"registerBroadcastTrigger","values":[{"type":"string","value":"AddPoint"}],"next":{"func":"blockVarChangeBy","values":[{"type":"string","value":"MyScore"},{"type":"number","value":"1"}]}} Add to my Backpack


{"func":"blockVarShow"}

Show Variable

"Show Variable" makes the specified variable appear on the Stage.

Parameters:

Variable: this parameter should be the name of one the variable you want to show up on the Stage.

Related Blocks:
{"func":"blockVarHide"}

Sample Code:
{"func":"blockControlIfElse","values":[{"type":"wrapper","func":"valueVarPropGet","values":[{"type":"string","value":"Playing"},{"type":"string","value":"stage"}]}],"containers":[{"func":"blockVarShow","values":[{"type":"string","value":"MyScore"}]},{"func":"blockVarHide","values":[{"type":"string","value":"MyScore"}]}]} Add to my Backpack


{"func":"blockVarHide"}

Hide Variable

"Hide Variable" makes the specified variable disappear on the Stage.

Parameters:

Variable: this parameter should be the name of one the variable you want to hide.

Related Blocks:
{"func":"blockVarShow"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockVarHide","values":[{"type":"string","value":"MyScore"}]}} Add to my Backpack