Motion

move

// Move a sprite by 10 steps
self.move(10);

turnLeft

// Turn the sprite counter-clockwise by the given number of degrees
self.turnLeft(15);

turnRight

// Turn the sprite clockwise by the given number of degrees
self.turnRight(15);

pointInDirection

// Point the sprite in a specified direction in degrees (0 is up, 90 is right)
self.pointInDirection(90);

pointTowards

// Point the sprite towards another specified sprite or the mouse pointer
self.pointTowards(self);

pointTo

// Point the sprite towards a specified (x, y) coordinate
self.pointTo(30, 30);

goTo

// Set the sprite's position to the specified (x, y) coordinates immediately
self.goTo(0, 0);

goTowards

// Go to the position of another specified sprite or the mouse pointer
self.goTowards(self);

glide

// Glide to a specified (x, y) coordinate over a specified duration in seconds
self.glide(1, 0, 1);

setX

// Set the sprite's x position to the specified value
self.x = 10;

setY

// Set the sprite's y position to the specified value
self.y = 10;

changeX

// Change a sprite's x position by a given amount
self.x += 10;

changeY

// Change a sprite's y position by a given amount
self.y += 10;

setRotationStyle

// Set the sprite's rotation style (e.g. all around, left-right, or dont rotate)
self.setRotationStyle("all around");

ifOnEdgeBounce

// If the sprite touches the edge of the screen, turn the sprite around
self.ifOnEdgeBounce();

x

// Get the current x position of the sprite
self.x;

y

// Get the current y position of the sprite
self.y;

direction

// Get the current direction the sprite is pointing in degrees
self.direction;

Looks

sayWait

// Make the sprite show a speech bubble for a number of seconds
self.sayWait("Hello!", 2);

say

// Make the sprite show a speech bubble
self.say("Hello!");

thinkWait

// Make the sprite show a thought bubble for a number of seconds
self.thinkWait("Hello!", 2);

think

// Make the sprite show a thought bubble
self.think("Hello!");

setEffect

// Set a graphic effect to a given value
self.effects.color = 100;

changeEffect

// Change a graphic effect by a given amount
self.effects.color += 10;

clearEffects

// Remove all graphic effects from the sprite
self.clearEffects();

switchCostumeTo

// Switch the sprite to a specific costume
self.switchCostumeTo("Scrappy");

nextCostume

// Switch the sprite to the next costume
self.nextCostume();

switchBackdropTo

// Switch the stage to a specific backdrop
self.switchBackdropTo("Stage");

switchBackdropToWait

// Switch the backdrop and wait until its scripts finish
self.switchBackdropToWait("Stage");

nextBackdrop

// Switch the stage to the next backdrop
self.nextBackdrop();

show

// Show the sprite
self.show();

hide

// Hide the sprite
self.hide();

setSize

// Set the sprite's size to a percentage
self.size = 100;

changeSize

// Change the sprite's size by a given amount
self.size += 10;

goForward

// Bring the sprite forward one layer
self.goForward();

goBackward

// Send the sprite backward one layer
self.goBackward();

goToFront

// Bring the sprite to the front layer
self.goToFront();

goToBack

// Send the sprite to the back layer
self.goToBack();

effect

// Get the current value of a graphic effect
self.effects.color;

visible

// Check whether the sprite is currently visible
self.visible;

size

// Get the sprite's current size as a percentage
self.size;

costume

// Get the name of the sprite's current costume
self.costume.name;

costumeIndex

// Get the index of the sprite's current costume
self.costume.index;

backdrop

// Get the name of the stage's current backdrop
self.backdrop.name;

backdropIndex

// Get the index of the stage's current backdrop
self.backdrop.index;

Sounds

playSound

// Start playing a sound without waiting for it to finish
self.playSound("click");

playSoundUntilDone

// Play a sound and wait until it finishes
self.playSoundUntilDone("click");

stopSounds

// Stop all sounds currently playing
self.stopSounds();

setVolume

// Set the sprite's volume to a percentage
self.volume = 100;

volume

// Get the current volume as a percentage
self.volume;

Pen

color

// Create a color from a hex value
Color.fromHex("#ff0000");

rgb

// Create a color from red, green and blue components
Color.fromRGB(255, 255, 255);

penClear

// Erase everything the pen has drawn on the stage
self.penClear();

penDown

// Put the pen down so the sprite draws as it moves
self.penDown();

penUp

// Lift the pen up so the sprite stops drawing
self.penUp();

stamp

// Stamp the sprite's image onto the stage
self.stamp();

setPenSize

// Set the pen's thickness
self.penSize = 100;

changePenSize

// Change the pen's thickness by a given amount
self.penSize += 1;

setPenColor

// Set the pen color
self.penColor = Color.fromHex("#ff0000");

penSize

// Get the current pen thickness
self.penSize;

penColor

// Get the current pen color
self.penColor;

isPenDown

// Check whether the pen is currently down
self.isPenDown;

Events

whenFlag

// Run code when the green flag is clicked
self.whenFlag(() => {});

whenLoaded

// Run code once the sprite has loaded
self.whenLoaded(() => {});

whenTimerElapsed

// Run code when the timer passes a number of seconds
self.whenTimerElapsed(1, () => {});

whenBackdropChangesTo

// Run code when the backdrop switches to a specific one
self.whenBackdropChangesTo("Stage", () => {});

whenKeyPressed

// Run code when a key is pressed
self.whenKeyPressed("any", () => {});

whenMouse

// Run code on a mouse event such as a click
self.whenMouse("clicked", () => {});

whenReceiveMessage

// Run code when a broadcast message is received
self.whenReceiveMessage("message", () => {});

broadcastMessage

// Broadcast a message to all sprites without waiting
self.broadcastMessage("message");

broadcastMessageWait

// Broadcast a message and wait until all receivers finish
self.broadcastMessageWait("message");

Controls

wait

// Pause the script for a number of seconds
self.wait(1);

for

// Count from one number to another, running code each time
for (let i = 1; i <= 10; i++) {}

while

// Repeat code while a condition is true
while (false) {}

doWhile

// Run code once and then repeat while a condition is true
do {} while (false);

break

// Exit the innermost loop immediately
break;

continue

// Skip to the next iteration of the loop
continue;

controls_if

// Run code only when a condition is true
if (false) {
}

controls_if_else

// Run one block of code or another depending on a condition
if (false) {
} else {
}

ternary

// Choose between two values depending on a condition
false ? null : null;

tryCatch

// Try to run code and catch any error it throws
try {
} catch (error) {}

throw

// Throw an error
throw "error";

whenCloned

// Run code when this sprite is cloned
self.whenCloned(() => {});

clone

// Create a clone of a sprite
self.clone();

delete

// Delete this clone
self.delete();

stop

// Stop the whole project
Scrap.stop();

stopOtherScripts

// Stop the other scripts running on this sprite
self.stopOtherScripts();

Sensing

isTouching

// Check whether the sprite is touching another sprite
self.isTouching(self);

isTouchingBackdropColor

// Check whether the sprite is touching a color on the backdrop
self.isTouchingBackdropColor(Color.fromHex("#ff0000"));

isTouchingEdge

// Check whether the sprite is touching the edge of the stage
self.isTouchingEdge();

isTouchingMouse

// Check whether the sprite is touching the mouse pointer
self.isTouchingMouse();

distanceTo

// Get the distance from the sprite to a point
self.distanceTo(0, 0);

ask

// Ask the user a question and wait for an answer
self.ask("What's your name?");

isKeyPressed

// Check whether a key is currently pressed
self.isKeyPressed("any");

mouseDown

// Check whether the mouse button is pressed
self.mouseDown;

mouseX

// Get the mouse pointer's x position
self.mouseX;

mouseY

// Get the mouse pointer's y position
self.mouseY;

width

// Get the width of the stage
self.width;

height

// Get the height of the stage
self.height;

property

// Get a property of another sprite or the stage
$["Stage"].width;

isTurbo

// Check whether turbo mode is enabled
Scrap.isTurbo();

draggable

// Check whether the sprite can be dragged
self.draggable;

setDraggable

// Set whether the sprite can be dragged
self.draggable = true;

resetTimer

// Reset the timer back to zero
self.resetTimer();

getTimer

// Get the number of seconds since the timer was reset
self.getTimer();

date

// Create a date from a specific calendar date
new Date("2026-06-30");

today

// Get the current date and time
new Date();

dateProperty_date

// Get a part (such as the year) of a specific date
new Date("2026-06-30").getFullYear();

dateProperty_today

// Get a part (such as the year) of the current date
new Date().getFullYear();

alert

// Show a browser alert dialog with a message
window.alert("Hello!");

prompt

// Show a browser prompt asking the user for text
window.prompt("What's your name?");

confirm

// Show a confirmation dialog and get a yes/no answer
window.confirm("Are you sure?");

Operators

math_number

// A number value
0;

arithmetics_add

// Add two numbers
10 + 10;

arithmetics_subtract

// Subtract one number from another
10 - 10;

arithmetics_multiply

// Multiply two numbers
10 * 10;

arithmetics_divide

// Divide one number by another
10 / 10;

arithmetics_power

// Raise a number to a power
10 ** 10;

arithmetics_modulo

// Get the remainder of dividing one number by another
10 % 10;

compare_equals

// Check whether two values are equal
0 == 0;

compare_notEquals

// Check whether two values are not equal
10 != 10;

compare_lessThan

// Check whether one value is less than another
10 < 10;

compare_lessThanOrEqual

// Check whether one value is less than or equal to another
10 <= 10;

compare_greaterThan

// Check whether one value is greater than another
10 > 10;

compare_greaterThanOrEqual

// Check whether one value is greater than or equal to another
10 >= 10;

operation_and

// True only when both values are true
false && false;

operation_or

// True when at least one value is true
false || false;

not

// Invert a boolean value
!false;

boolean

// A true or false value
true;

math

// Apply a math function such as absolute value
Math.abs(0);

random

// Get a random number between 0 and 1
Math.random();

constant

// A mathematical constant such as Pi
Math.PI;

string

// Convert a value to text
String(0);

number

// Convert a value to a number
Number("");

type

// A type such as number, string or boolean
any;

generic

// A generic type such as an array of a given type
Array<any>;

union

// A type that can be one of several types
number | string;

Iterables

iterables_string

// A piece of text
"";

array

// Create an array (list) of values
new Array(0, 0);

length

// Get the number of items in an array
[].length;

reverse

// Reverse the order of an array
[].reverse();

join

// Join the items of an array into text
[].join(", ");

includes

// Check whether an array contains a value
[].includes(null);

slice

// Get a section of an array between two indexes
[].slice(0, 2);

item

// Get the item at a given index of an array
[][0];

indexOf

// Get the position of a value within an array
[].indexOf(null);

foreach

// Run code for each item in an array
for (const item of []) {
}

Functions

function

// Define a reusable function
function foo(): void {}

return

// Return a value from a function
return;