-
Notifications
You must be signed in to change notification settings - Fork 0
Using Amberscript
TODO:
- branches (blackhole)
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.new <identifier> <costume> <x> <y>
Creates a new object with the identifier <identifier> at the coordinates <x> <y> with the costume <costume>
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 <identifier>
Deletes the Object <identifier>
render.move <identifier> <x> <y>
Teleports the object <identifier> to the coordinates <x> <y>.
Replace any with ~ to keep it the same
render.smoothmove <identifier> <x> <y>
Smoothly move the object <identifier> to the coordinates <x> <y>. (Smoothness determined by the anim.smooth property)
render.get <identifier> <property>
Get the property <property> of the object <identifier>.
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 <identifier>
! <identifier>
Run the function <identifier>.
? <identifier>
Run the function lib.<identifier>.
variable.set <identifier> <value>
Set the variable <identifier> to <value>.
variable.operation <identifier> <operation> <value>
Run <operation> on the variable <identifier> with the value <value>.
Valid operations are: +, -, *, /, %, ^, sin, cos, tan
To all AmberScript devs: Rework listeners to work like this
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 <identifier>
Stop the listener <identifier>.
condition.eval <v1> <type> <v2> <variable>
Evaluate the condition <type> with the values <v1> and <v2> and store the result to <variable>
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.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 <identifier>
Deletes the Text Object ```
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>
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.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.if <boolean> <function>
Runs the function <function> if <boolean> matches true or 1.
Also see: condition.eval
branch.repeat <amount> <function>
Repeat the function <function> <amount> times.
branch.loop <boolean> <endval> <function>
Repeats the function <function> until <boolean> matches <endval>.
Caution: This function may cause crashes if the condition never happens!
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(<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(<object>,<property>)
This variable type returns the value of the property <property> of the object <object>.
$r(<min>,<max>)
This just returns a random value between <min> and <max>. Works like the normal pick between <x> and <y> block.
$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(<identifier>)
Returns the value of the system variable <identifier>.
System Variables are Stored in the savecode and retrieved back when loaded.
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.
Runs when the Object starts being clicked.
Runs when the Object starts being hovered.
Runs while the Object is being hovered.
Runs every Frame.
Waits [arg1] seconds before running the function.
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
The current x position of the Object. (Teleports when changed)
The current y position of the Object. (Teleports when changed)
The goal x position of the Object. (Glide)
The goal y position of the Object. (Glide)
The smoothing of the Object Gliding to another Position
#### sprite.visible If the sprite is visible or not. (true/false)
The current Ghost Effect of the object. (Direct)
The goal ghost effect of the object. (Smooth)
The smoothing of the goal Ghost effect transition.
The current layer of the object in the system.
The current size of the object.
The goal size of the object. (Smooth)
The smoothing of the goal object size transition.