Skip to content

Using Amberscript

ItsGraphax edited this page May 23, 2025 · 15 revisions

TODO:

  • branches (blackhole)

Functions

AmberScript is pretty versatile and has many functions. They are all wroten in "category.function" and likewise pretty easy to find. Here are all Functions written down, sorted into categories.

render

render.new

render.new <identifier> <costume> <x> <y>

Creates a new object with the identifier <identifier> at the coordinates <x> <y> with the costume <costume>

render.modify

render.modify <identifier> <property> <value>

Changes the property <property> of the object <identifier> to <value>. Find a list of properties under the properties page

render.delete

render.delete <identifier>

Deletes the Object <identifier>

render.move

render.move <identifier> <x> <y>

Teleports the object <identifier> to the coordinates <x> <y>. Replace any with ~ to keep it the same

render.smoothmove

render.smoothmove <identifier> <x> <y>

Smoothly move the object <identifier> to the coordinates <x> <y>. (Smoothness determined by the anim.smooth property)

render.get

render.get <identifier> <property>

Get the property <property> of the object <identifier>.

function

function.register

function.register <identifier> <commands>

Register the function <identifier> with the commands <commands>. Split the commands by the \c escape. (If used in this command write \\c)

function.run (alias !)

function.run <identifier>
! <identifier>

Run the function <identifier>.

?

? <identifier>

Run the function lib.<identifier>.

variable

variable.set

variable.set <identifier> <value>

Set the variable <identifier> to <value>.

variable.operation

variable.operation <identifier> <operation> <value>

Run <operation> on the variable <identifier> with the value <value>. Valid operations are: +, -, *, /, %, ^, sin, cos, tan

listener

To all AmberScript devs: Rework listeners to work like this

listener.start

listener.start <identifier> <object> <type> <function> [arg1] [arg2]

Start a listener as <identifier> as the object <object> for <type> and run the function <function> when the condition is met. Some Listener Types may also accept [arg1] and/or [arg2] See a full list of listener types in the listeners.

listener.stop

listener.stop <identifier>

Stop the listener <identifier>.

condition

condition.eval

condition.eval <v1> <type> <v2> <variable>

Evaluate the condition <type> with the values <v1> and <v2> and store the result to <variable>

system

system.setvar

system.setvar <identifier> <value>

Sets the value of the system variable <identifier> to <value> System variables are stored in the savecode and loaded when logging in.

text

text.create

text.create <text> <x> <y> <color> <brightness> <identifier> <align>

Creates a Text Object at <x> <y> with the text <text>, with the <color> and <brightness> aligned to <align> with the identifier <identifier> <align> options are: l, m, r <color> and <brightness> determine the scratch "color" and "brightness" effect.

Warning: A Text Object does not function like an Object and does not support any functions except the ones in the category text.

text.delete

text.delete <identifier>

Deletes the Text Object ```

text.modify

text.modify <text> <x> <y> <color> <brightness> <identifier> <align>

Deletes the Text Object <identifier> and creates a new one at <x> <y> with the text <text>, with the <color> and <brightness> aligned to <align> with the identifier <identifier> <align> options are: l, m, r <color> and <brightness> determine the scratch "color" and "brightness" effect.

text.print

text.print <text>

Directly Runs the Internal Function of the Text Engine to Print <text> with the same arguments as the last text.create function. Should almost never be used.

shell

### shell.run

shell.run <shell command> [arguments]...

Runs an AmberOS shell command.

AmberOS Shell Commands are a SubSystem of AmberScript and directly modify internal System Data like Files and Folders. A list of Shell commands are found in.

branch

branch.if

branch.if <boolean> <function>

Runs the function <function> if <boolean> matches true or 1. Also see: condition.eval

branch.repeat

branch.repeat <amount> <function>

Repeat the function <function> <amount> times.

branch.loop

branch.loop <boolean> <endval> <function>

Repeats the function <function> until <boolean> matches <endval>. Caution: This function may cause crashes if the condition never happens!

Variables

AmberScript, like any other Programming Language, allows the use of Variables. But in AmberScript, they are written and used a bit differently than in normal Programming Languages.

To use a variable you have $x(y,z). x stands for the variable type, y for the first argument and z for the optional second argument. These special codes (starting with $) evaluate the variable type and directly inject the text into the command. Each variable type handles the inputs differently.

## Variable Types

v for variable

$v(<identifier>)

This is the most common variable type and just returns the value of the variable <identifier>. You can control variables with any function in the variable category.

p for property

$p(<object>,<property>)

This variable type returns the value of the property <property> of the object <object>.

r for random

$r(<min>,<max>)

This just returns a random value between <min> and <max>. Works like the normal pick between <x> and <y> block.

f for function

$f(<i>)

Returns the argument <i> of the currently run function.

### i for input

$i(<input type>, [arg])

Returns a value for <input type>

  • key: returns true if the key [arg] is pressed, else false
  • mouse: Below is a list of all values mouse could return based on [arg]
    • x: returns the x position of the mouse
    • y: returns the y position of the mouse
    • d: returns true if the mouse is down, else false
  • hover: returns true if the object [arg] is being currently hovered, else false
  • click (fallback): returns true if the object [arg] is currently being clicked, else false

s for system variable

$s(<identifier>)

Returns the value of the system variable <identifier>. System Variables are Stored in the savecode and retrieved back when loaded.

Listeners

Listeners are started with the function listener.start and create (modify) a new separate thread for the selected object that listens for the given action defined by the listener type and runs a function if the condition is met. Below is a list of valid listener types.

Listener Types

onClickEvent

Runs when the Object starts being clicked.

onHoverEvent

Runs when the Object starts being hovered.

hoverEvent

Runs while the Object is being hovered.

tick

Runs every Frame.

timeout

Waits [arg1] seconds before running the function.

Objects

Objects are Clones that together build AmberOS and its Applications. You are able to control them with any function of the (render)[##render] category.

Objects also support listeners.

All Objects have a set of Properties controlled with the render.modify. Below is a full list of all properties an Object has.

## Object Properties

position

position.x.current

The current x position of the Object. (Teleports when changed)

position.y.current

The current y position of the Object. (Teleports when changed)

position.x.goal

The goal x position of the Object. (Glide)

position.y.goal

The goal y position of the Object. (Glide)

position.smoothing

The smoothing of the Object Gliding to another Position

sprite

#### sprite.visible If the sprite is visible or not. (true/false)

sprite.ghost

sprite.ghost.current

The current Ghost Effect of the object. (Direct)

sprite.ghost.to

The goal ghost effect of the object. (Smooth)

sprite.ghost.smoothing

The smoothing of the goal Ghost effect transition.

sprite.layer

The current layer of the object in the system.

sprite.size

sprite.size.current

The current size of the object.

sprite.size.goal

The goal size of the object. (Smooth)

sprite.size.smoothing

The smoothing of the goal object size transition.