scratch
Fields
Here are the fields provided by this builtin:
| Field name | Field description |
|---|---|
backdrop.name |
The name of the current backdrop |
backdrop.number |
The costume number of the current backdrop |
answer |
The answer given by the user to a scratch.ask(...) query |
mouse_down |
If the left mouse button is clicked or the screen is touched |
mouse_x |
The current X position of the mouse or finger on the screen |
mouse_y |
The current Y position of the mouse or finger on the screen |
loudness |
The current input volume of the microphone as a percentage |
username |
The detected username of the user running the project |
Methods
Here are the methods provided by this builtin that should be used in an expression rather than as a statement:
| Method name | Method parameters | Method description |
|---|---|---|
key_pressed |
key |
Returns whether or not key is currently pressed |
get_attribute |
attribute, target |
Returns the attribute attribute of target |
Possible values for key:
- Any character in the range U+0021 to U+007E
C.SPACEC.ENTERC.UP_ARROWC.DOWN_ARROWC.LEFT_ARROWC.RIGHT_ARROW
Possible values for attribute:
C.VOLUME- If
targetis the stage:C.BACKDROP_NAMEC.BACKDROP_NUMBER
- Otherwise:
C.X_POSITIONC.Y_POSITIONC.DIRECTIONC.COSTUME_NUMBERC.COSTUME_NAMEC.SIZE
Possible values for target:
C.STAGE- Any sprite name
Here are the methods provided by this builtin that should be used as a statement rather than in an expression:
| Method name | Method parameters | Method description |
|---|---|---|
stop |
mode |
Stops a certain aspect of the project according to mode |
ask |
query |
Asks query with a message box and waits for the user’s response, stored in scratch.answer |
broadcast |
broadcast, [message] |
Broadcasts broadcast to the project with an optional message |
broadcast_and_wait |
broadcast, [message] |
Broadcasts broadcast to the project with an optional message and waits for all listeners to finish running |
clone |
[target] |
Creates a clone of the current sprite or another one |
delete_clone |
None | Deletes the clone this method is ran on |
Possible values for mode:
C.ALLC.OTHER_SCRIPTSC.THIS_SCRIPT
Possible values for message:
- Anything except a list
Possible values for target:
C.MYSELF(default for when called without any arguments)- Any sprite name