Control Blocks

Delay

{"func":"blockControlWait"}

Wait

"Wait" block waits for the specified number of seconds before continuing the script.

Related Blocks:
{"func":"blockControlWaitUntil"} ,     {"func":"blockMotionMove"} ,     {"func":"blockLooksSay"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockMotionRotationStyle","values":[{"type":"choice","value":"left-right"}],"next":{"func":"blockControlForever","containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockMotionBounceOnEdge","next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}]}}}]}}} Add to my Backpack


Debugging

{"func":"blockControlDebugBreak"}

Breakpoint

"Breakpoint" block will cause the program to temporarily pause at the location to allow debugging. Breakpoints can be added in the problem areas of the program to inspect the variables and conditions while testing.

Related Blocks:
{"func":"blockControlDebugBreakOn"}

Sample Code:
{"func":"blockSensingAskChoices","values":[{"type":"string","value":"Yes or no"},{"type":"string","value":"ok"}],"next":{"func":"blockControlDebugBreak"}} Add to my Backpack


{"func":"blockControlDebugBreakOn"}

Breakpoint when Condition

"Breakpoint when Condition" block waits for a condition to occur before temporarily pausing the program for debugging. Breakpoints can be added in the problem areas of the program to inspect the variables and conditions while testing.

Related Blocks:
{"func":"blockControlDebugBreak"}

Sample Code:
{"func":"blockControlDebugBreakOn","values":[{"type":"wrapper","func":"valueOpBinary","values":[{"type":"wrapper","func":"valueMotionXPosition"},{"type":"choice","value":">"},{"type":"string","value":"0"}]}]} Add to my Backpack


Advanced

{"func":"blockControlStop"}

Stop

"Stop" stops whatever scripts are specified by the parameter (all the scripts, this block, or the Actor’s scripts).

Parameters:

Script to stop: this parameter indicates which scripts you want to stop. You may select "all," "this script," or "other scripts in Actor."

Sample Code:
{"func":"registerTrigger","values":[{"type":"wrapper","func":"valueOpNot","values":[{"type":"wrapper","func":"valueVar","name":"Playing"}]}],"next":{"func":"blockControlStop","values":[{"type":"choice","value":"all"}]}} Add to my Backpack


Conditionals

{"func":"blockControlIf"}

If

"If" Flow block runs the code inside it only if given condition is true.

Parameters:

Condition: this parameter should be a boolean value that determines whether or not the code inside the "if" block runs.

Related Blocks:
{"func":"blockControlIfElse"} ,     {"func":"valueControlIfElse"}

Sample Code:
{"func":"registerCloned","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueVar","name":"Playing"}],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueOpRandom","values":[{"type":"number","value":"1"},{"type":"number","value":"10"}]},{"type":"string","value":"5"}]}],"containers":[{"func":"blockMotionTurnCW","values":[{"type":"string","value":"15"}]}]}}}]}} Add to my Backpack


{"func":"blockControlIfElse"}

If Else

"If Else" Flow block runs the code inside the "if" if the parameter is true and the code inside the "else" if the parameter is false (but not both).

Parameters:

Condition: this parameter should be a boolean value that determines whether the code inside the "if" or "else" part runs.

Related Blocks:
{"func":"blockControlIf"} ,     {"func":"valueControlIfElse"}

Sample Code:
{"func":"registerSpriteCollision","next":{"func":"blockControlIfElse","values":[{"type":"wrapper","func":"valuePhysicsCollidedWithSprite","values":[{"type":"string","value":"Ball"}]}],"containers":[{"func":"blockControlPostMessageAndWait","values":[{"type":"string","value":"Add Point"},{"type":"string","value":"any"},{"type":"wrapper","func":"valueVar","name":"CurrentScore"}]},{"func":"blockControlPostMessage","values":[{"type":"string","value":"Subtract Point"},{"type":"string","value":"stage"},{"type":"wrapper","func":"valueVar","name":"CurrentScore"}]}]}} Add to my Backpack


{"func":"valueControlIfElse"}

If Then Else

"If Then Else" returns the second parameter if the first parameter is true, and the third parameter if the first parameter is false.

Parameters:

Condition: this parameter should be a boolean value that determines which of the next two parameters will be returned.

Return Value 1: this parameter will be returned if the condition parameter is true.

Return Value 2: this parameter will be returned if the condition parameter is false.

Related Blocks:
{"func":"blockControlIf"} ,     {"func":"blockControlIfElse"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockPenDrawText","values":[{"type":"wrapper","func":"valueControlIfElse","values":[{"type":"wrapper","func":"valueVar","name":"Playing"},{"type":"string","value":"Pause"},{"type":"string","value":"Play"}]}]}} Add to my Backpack


Loops

{"func":"blockControlForever"}

Forever

"Forever" block repeats the script inside over and over.

Parameters:

None.

Related Blocks:
{"func":"blockControlRepeat"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlWhile"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockMotionRotationStyle","values":[{"type":"choice","value":"left-right"}],"next":{"func":"blockControlForever","containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockMotionBounceOnEdge","next":{"func":"blockControlWait","values":[{"type":"number","value":".1"}]}}}]}}} Add to my Backpack


{"func":"blockControlRepeat"}

Repeat

"Repeat" block repeats the script inside the specified number of times.

Parameters:

NumRepeats: this parameter indicates how many times you should repeat the code inside this block.

Related Blocks:
{"func":"blockControlForever"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlWhile"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockControlRepeat","values":[{"type":"number","value":"10"}],"containers":[{"func":"blockMotionTurnCCW","values":[{"type":"string","value":"15"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":".5"}]}}]}} Add to my Backpack


{"func":"blockControlForeverIf"}

Forever If

"Forever If" Flow block acts like a normal forever loop but only continues looping while the parameter is true.

Parameters:

Condition: this parameter should be a boolean value that determines whether or not the forever loop continues running the code inside it.

Related Blocks:
{"func":"blockControlRepeat"} ,     {"func":"blockControlForever"} ,     {"func":"blockControlWhile"}

Sample Code:
{"func":"registerCloned","next":{"func":"blockControlForeverIf","values":[{"type":"wrapper","func":"valueVar","name":"Playing"}],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"10"}],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueOpRandom","values":[{"type":"number","value":"1"},{"type":"number","value":"10"}]},{"type":"string","value":"5"}]}],"containers":[{"func":"blockMotionTurnCW","values":[{"type":"string","value":"15"}]}]}}}]}} Add to my Backpack


{"func":"blockControlWaitUntil"}

Wait Until

"Wait Until" pauses the given script until the parameter is equivalent to true.

Parameters:

Condition: this parameter should be a boolean value that determines when the block will stop waiting.

Related Blocks:
{"func":"blockControlWait"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockControlWaitUntil","values":[{"type":"wrapper","func":"valueSensingTouchingSprite","values":[{"type":"string","value":"right edge"}]}],"next":{"func":"blockLooksThinkFor","values":[{"type":"string","value":"Turn me around!"},{"type":"number","value":"5"}]}}} Add to my Backpack


{"func":"blockControlWhile"}

Repeat While

"Repeat While" performs the code inside it while the parameter is still true.

Parameters:

Condition: this parameter should be a boolean value that determines when the block should stop repeating the code inside it.

Related Blocks:
{"func":"blockControlRepeat"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlForever"}

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":"blockControlRepeatUntil"}

Repeat Until

"Repeat Until" performs the code inside it until llthe parameter is true

Parameters:

Condition: this parameter should be a boolean value that determines when the block should stop repeating the code inside it.

Related Blocks:
{"func":"blockControlRepeat"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlForever"} ,     {"func":"blockControlWhile"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockControlRepeatUntil","values":[{"type":"wrapper","func":"valueOpNot","values":[{"type":"wrapper","func":"valueVar","name":"Playing"}]}],"containers":[{"func":"blockSoundChangeVolume","values":[{"type":"number","value":"1"}]}]}} Add to my Backpack


{"func":"blockControlFor"}

For

"For" block repeats the script inside the specified number of times and updates the variable specified by the first parameter.

Parameters:

Variable: this parameter indicates the variable to update.

From: this parameter indicates the starting value.

To: this parameter indicates the ending value.

StepBy: this parameter indicates the value to skip by (usually 1).

Related Blocks:
{"func":"blockControlForever"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlWhile"} ,     {"func":"blockControlForEach"} ,     {"func":"blockControlBreak"} ,     {"func":"blockControlContinue"}

Sample Code:
{"func":"registerSpriteTrigger","next":{"func":"blockControlScriptVar","cat":"var","label":"script variables {scriptvar:i}{varargs:valueScriptVar}","values":[{"type":"wrapper","func":"valueScriptVar","name":"i"}],"next":{"func":"blockControlFor","values":[{"type":"wrapper","func":"valueScriptVar","name":"i"},{"type":"number","value":"0"},{"type":"number","value":"10"},{"type":"number","value":"1"}],"containers":[{"func":"blockMotionChangeXBy","values":[{"type":"wrapper","func":"valueOpMultiply","values":[{"type":"wrapper","func":"valueScriptVar","name":"i"},{"type":"number","value":10}]}],"next":{"func":"blockControlWait","values":[{"type":"number","value":0.5}]}}]}}} Add to my Backpack


{"func":"blockControlForEach"}

For Each

"For Each" block iterates over all the values in the specified variable.

Parameters:

Variable: a variable or list containing the list of values to iterate over.

As: this parameter indicates the variable to update.

Related Blocks:
{"func":"blockControlForever"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlWhile"} ,     {"func":"blockControlFor"} ,     {"func":"blockControlBreaks"} ,     {"func":"blockControlContinue"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockListDel","values":[{"type":"choice","value":"all"},{"type":"string","value":"fruits"}],"next":{"func":"blockListAdd","values":[{"type":"string","value":"apple"},{"type":"string","value":"orange"},{"type":"string","value":"mango"},{"type":"string","value":"peach"},{"type":"string","value":"fruits"}],"next":{"func":"blockControlPrint","values":[{"type":"wrapper","func":"valueList","name":"fruits"}],"next":{"func":"blockControlPrint","values":[{"type":"wrapper","func":"valueListLength","values":[{"type":"string","value":"fruits"}]}],"next":{"func":"blockControlScriptVar","cat":"var","label":"script variables {scriptvar:afruit}{varargs:valueScriptVar}","values":[{"type":"wrapper","func":"valueScriptVar","name":"afruit"}],"next":{"func":"blockControlForEach","values":[{"type":"wrapper","func":"valueList","name":"fruits"},{"type":"string","value":"afruit"}],"containers":[{"func":"blockLooksSayFor","values":[{"type":"wrapper","func":"valueOpJoin","values":[{"type":"string","value":"Fruit: "},{"type":"wrapper","func":"valueScriptVar","name":"afruit"}]},{"type":"number","value":"2"}]}]}}}}}}} Add to my Backpack


{"func":"blockControlBreak"}

Break

"Break" exits out of a loop

Parameters:

None.

Related Blocks:
{"func":"blockControlForever"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlWhile"} ,     {"func":"blockControlFor"} ,     {"func":"blockControlForEach"} ,     {"func":"blockControlContinue"}

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":"1"}]}],"containers":[{"func":"blockControlBreak"}]}]}} Add to my Backpack


{"func":"blockControlContinue"}

Continue

"Continue" skips the rest of the blocks in the loop and continues the next loop cycle.

Parameters:

None.

Related Blocks:
{"func":"blockControlForever"} ,     {"func":"blockControlForeverIf"} ,     {"func":"blockControlWhile"} ,     {"func":"blockControlFor"} ,     {"func":"blockControlForEach"} ,     {"func":"blockControlBreak"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockControlScriptVar","cat":"var","label":"script variables {scriptvar:i}{varargs:valueScriptVar}","values":[{"type":"wrapper","func":"valueScriptVar","name":"i"}],"next":{"func":"blockInlineComment","values":[{"type":"string","value":"Skip all numbers divisible by 3"}],"next":{"func":"blockControlFor","values":[{"type":"string","value":"i"},{"type":"number","value":1},{"type":"number","value":20},{"type":"number","value":"1"}],"containers":[{"func":"blockControlIf","values":[{"type":"wrapper","func":"valueOpEqual","values":[{"type":"wrapper","func":"valueOpMod","values":[{"type":"wrapper","func":"valueScriptVar","name":"i"},{"type":"number","value":3}]},{"type":"string","value":"0"}]}],"containers":[{"func":"blockControlContinue"}],"next":{"func":"blockLooksSayFor","values":[{"type":"wrapper","func":"valueScriptVar","name":"i"},{"type":"number","value":"2"}]}}]}}}} Add to my Backpack


Cloning

{"func":"blockControlCloneActor"}

Create Clone of Actor

"Create Clone of Actor" block clones the specified Actor and activates the "Clone Startup" block.

Parameters:

Actor: this parameter indicates which Actor to clone.

Related Blocks:
{"func":"registerCloned"} ,     {"func":"valueControlLastClonedActor"} ,     {"func":"blockControlDeleteActor"}

Sample Code:
{"func":"registerSpriteTrigger","next":{"func":"blockControlCloneActor","values":[{"type":"string","value":"self"}]}} Add to my Backpack


{"func":"valueControlLastClonedActor"}

Name of Last Cloned Actor

"Name of Last Cloned Actor" block returns the name of the last cloned Actor.

Parameters:

None.

Related Blocks:
{"func":"registerCloned"} ,     {"func":"blockControlDeleteActor"}

Sample Code:
{"func":"registerTrigger","values":[{"type":"wrapper","func":"valueVar","name":"Clone"}],"next":{"func":"blockLooksThink","values":[{"type":"string","value":"I want another"},{"type":"wrapper","func":"valueControlLastClonedActor"},{"type":"string","value":"!"}]}} Add to my Backpack


{"func":"valueControlCloneName"}

Clone Name of Actor

"Clone Name of Actor" block returns the original name of the cloned Actor passed in the parameter. If not a clone, will return the name of the Actor.

Parameters:

Actor: this parameter indicates the name of the cloned Actor whose original Actor you want the name of.

Related Blocks:
{"func":"registerCloned"} ,     {"func":"valueControlLastClonedActor"} ,     {"func":"blockControlDeleteActor"}


{"func":"valueControlIsClone"}

Is Clone?

"Is Clone?" checks to see if the current actor is a clone.

Parameters:

None.

Related Blocks:
{"func":"blockControlCloneActor"} ,     {"func":"valueControlLastClonedActor"} ,     {"func":"blockControlDeleteActor"}


{"func":"blockControlDeleteActor"}

Delete This Clone

"Delete This Clone" Flow block deletes the cloned Actor that the script above it refers to.

Parameters:

None.

Related Blocks:
{"func":"registerCloned"} ,     {"func":"valueControlLastClonedActor"} ,     {"func":"valueControlCloneName"}

Sample Code:
{"func":"registerCloned","next":{"func":"blockControlWait","values":[{"type":"number","value":"5"}],"next":{"func":"blockControlDeleteActor"}}} Add to my Backpack