Events Blocks

Event Handlers

{"func":"registerFlagTrigger"}

On Start

"On Start" is an event block that will activate when the start button is clicked.

Parameters:

None.

Related Blocks:
{"func":"registerKeyTrigger"} ,     {"func":"registerSpriteTrigger"} ,     {"func":"registerBroadcastTrigger"}

Sample Code:
{"func":"registerFlagTrigger","next":{"func":"blockLooksSetBubble","values":[{"type":"choice","value":"rectangular"}],"next":{"func":"blockLooksSayFor","values":[{"type":"string","value":"hello world"},{"type":"number","value":"2"}]}}} Add to my Backpack


{"func":"registerSpriteTrigger"}

When Actor Clicked

"When Actor Clicked" is an event block that activates when the actor is clicked on with the mouse.

Parameters:

None.

Related Blocks:
{"func":"registerFlagTrigger"} ,     {"func":"registerKeyTrigger"} ,     {"func":"registerBroadcastTrigger"}

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


{"func":"registerKeyTrigger"}

When Key Pressed

"When Key Pressed" is an event block that activates when the selected key is pressed.

Parameters:

Key: this parameter indicates the key that this method will listen for (up arrow, down arrow, etc).

Related Blocks:
{"func":"registerFlagTrigger"} ,     {"func":"registerSpriteTrigger"} ,     {"func":"registerBroadcastTrigger"}

Sample Code:
{"func":"registerKeyTrigger","values":[{"type":"choice","value":"right arrow"}],"next":{"func":"blockMotionPointTowards","values":[{"type":"string","value":"right edge"}],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"5"}]}}} Add to my Backpack


{"func":"registerBroadcastTrigger"}

When I Receive

"When I Receive" is an event block that listens for a broadcast or message from other scripts before activating.

Parameters:

Message: this parameter should be the name of some message that is broadcasted in a "broadcast" block or "send message" block. when either of those blocks send the message, this block will activate.

Related Blocks:
{"func":"blockControlPostMessage"} ,     {"func":"blockControlPostMessageAndWait"} ,     {"func":"valueControlMessageValue"} ,     {"func":"valueControlMessageSource"} ,     {"func":"blockControlBroadcast"}

Sample Code:
{"func":"registerBroadcastTrigger","values":[{"type":"string","value":"game over"}],"next":{"func":"blockLooksHide"}} Add to my Backpack


{"func":"registerTrigger"}

When Condition Occurs

"When Condition Occurs" is an event block that activates when the specified condition changes from the false state to the true state.

Parameters:

Condition: this parameter indicates the condition that will trigger this script.

Related Blocks:
{"func":"registerFlagTrigger"} ,     {"func":"registerSpriteTrigger"} ,     {"func":"registerBroadcastTrigger"}


{"func":"registerCloned"}

Clone Startup

"Clone Startup" runs the script after an actor has been cloned.

Parameters:

None.

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

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

When Background Switches

"When Background Switches" is an event block that activates when scene switches to the indicated scene.

Parameters:

Background: when your switches to this scene, this code block will activate. you can choose "any" as the parameter if you want the code block to activate whenever the scene changes, regardless of the new scene.

Related Blocks:
{"func":"blockLooksSwitchBackground"} ,     {"func":"blockLooksNextBackground"} ,     {"func":"blockLooksFirstBackgroundInGroup"}

Sample Code:
{"func":"registerBackgroundChange","values":[{"type":"string","value":"game over"}],"next":{"func":"blockSoundPlay","values":[{"type":"string","value":"gamesound8"}]}} Add to my Backpack


Events

{"func":"blockControlBroadcast"}

Broadcast

"Broadcast" is an event block that will broadcast a given message to the entire program while continuing to run the script.

Parameters:

Message: this is the message that this code block will broadcast. name it anything you want, depending on what action you want it to activate.

Related Blocks:
{"func":"blockControlBroadcastWait"} ,     {"func":"registerBroadcastTrigger"}

Sample Code:
{"func":"registerSpriteCollision","next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valuePhysicsCollidedWithSprite","values":[{"type":"string","value":"bottom edge"}]}],"containers":[{"func":"blockControlBroadcast","values":[{"type":"string","value":"game over"}]}]}} Add to my Backpack


{"func":"blockControlBroadcastWait"}

Broadcast And Wait

"Broadcast and Wait" is an event block that will broadcast a given message to entire program and wait until all activated scripts finish running.

Parameters:

Message: this is the message that this code block will broadcast. name it anything you want, depending on what action you want it to activate.

Related Blocks:
{"func":"blockControlBroadcast"} ,     {"func":"registerBroadcastTrigger"}

Sample Code:
{"func":"registerSpriteCollision","next":{"func":"blockControlIf","values":[{"type":"wrapper","func":"valuePhysicsCollidedWithSprite","values":[{"type":"string","value":"bottom edge"}]}],"containers":[{"func":"blockControlBroadcastWait","values":[{"type":"string","value":"game over"}]}]}} Add to my Backpack


{"func":"blockControlPostMessage"}

Send Message

"Send Message" block sends an event message to specified Actors with an optional parameter.

Parameters:

Message: This is the message that this code block will broadcast. Name it anything you want, depending on what action you want it to activate.

Actor: This is the Actor that will listen for your message. You can also choose "any" or "self."

Optional: You can use this parameter to pass in additional data, like a variable or list.

Related Blocks:
{"func":"blockControlPostMessageAndWait"} ,     {"func":"valueControlMessageValue"} ,     {"func":"valueControlMessageSource"} ,     {"func":"registerBroadcastTrigger"}

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

Send Message And Wait

"Send Message And Wait" is an event block that works the same as "Send Message," but waits until the activated scripts finish running before returning to code beneath this block.

Parameters:

Message: this is the message that this code block will broadcast. name it anything you want, depending on what action you want it to activate.

Actor: this is the actor that will listen for your message. you can also choose "any" or "self."

Optional: you can use this parameter to pass in additional data, like a variable or list.

Related Blocks:
{"func":"blockControlPostMessage"} ,     {"func":"valueControlMessageValue"} ,     {"func":"valueControlMessageSource"} ,     {"func":"registerBroadcastTrigger"}

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

Received Value

"Received Value" block returns the value of the received message.

Parameters:

None.

Related Blocks:
{"func":"blockControlPostMessage"} ,     {"func":"blockControlPostMessageAndWait"} ,     {"func":"valueControlMessageSource"} ,     {"func":"registerBroadcastTrigger"}

Sample Code:
{"func":"registerBroadcastTrigger","values":[{"type":"string","value":"AddPoint"}],"next":{"func":"blockLooksSay","values":[{"type":"wrapper","func":"valueControlMessageSource"},{"type":"string","value":"has"},{"type":"wrapper","func":"valueOpAdd","values":[{"type":"wrapper","func":"valueControlMessageValue"},{"type":"number","value":"1"}]},{"type":"string","value":"points!"}]}} Add to my Backpack


{"func":"valueControlMessageSource"}

Received Source

"Received Source" block returns the source of the received message.

Parameters:

None.

Related Blocks:
{"func":"blockControlPostMessage"} ,     {"func":"blockControlPostMessageAndWait"} ,     {"func":"valueControlMessageValue"} ,     {"func":"registerBroadcastTrigger"}

Sample Code:
{"func":"registerBroadcastTrigger","values":[{"type":"string","value":"AddPoint"}],"next":{"func":"blockLooksSay","values":[{"type":"wrapper","func":"valueControlMessageSource"},{"type":"string","value":"has"},{"type":"wrapper","func":"valueOpAdd","values":[{"type":"wrapper","func":"valueControlMessageValue"},{"type":"number","value":"1"}]},{"type":"string","value":"points!"}]}} Add to my Backpack


Documentation

{"func":"blockInlineComment"}

Comment

"Comment" performs no action but is useful for documenting your code.

Parameters:

None.

Sample Code:
{"func":"blockInlineComment","values":[{"type":"string","value":"point left"}],"next":{"func":"blockMotionPointDirection","values":[{"type":"string","value":-90}]}} Add to my Backpack


{"func":"blockComment","width":100,"height":24,"label":"code notes

Code Notes

"Code Notes" performs no action but is useful for documenting and explaining your code.

Parameters:

None.

Sample Code:
{"func":"blockComment","width":192.0028419494629,"height":34.821044921875,"label":"Map keys 'a', 's', 'd' and 'f' to control the actor."} Add to my Backpack


Advanced

{"func":"registerExternalTrigger"}

When External Condition Occurs

"When Exetrnal Condition Occurs" is an event block that activates when the specified external condition changes from the false state to the true state.

Parameters:

Condition: this parameter indicates the external condition - loudness, video motion or timer - that will trigger this script.

Value: set to the value to trigger this script.

Related Blocks:
{"func":"registerTrigger"}