Skip to content
Shylie edited this page Apr 7, 2020 · 7 revisions

Operators available in all versions

aslong

Converts the top of the stack into a long, if possible.

asdouble

Converts the top of the stack into a double, if possible.

add

Pops the top two values on the stack and pushes their sum to the stack (adds them).

  • 1 2 add leaves 3 on the stack.

sub

Pops the top two values on the stack and pushes their difference to the stack (subtracts them).

  • 1 2 sub leaves -1 on the stack.

mul

Pops the top two values on the stack and pushes their quotient to the stack (multiplies them).

  • 2 3 mul leaves 6 on the stack.

div

Pops the top two values on the stack and pushes their quotient to the stack (divides them).

  • 6 3 div leaves 2 on the stack.

exp (since 6c345a9)

Pops the top two values on the stack and pushes the second popped number raised to the power of the first.

  • 3.0 2.0 exp leaves 9.0 on the stack.
  • 4.0 0.5 exp leaves 2.0 on the stack.

lt

Pops the top two values on the stack and pushes true if the second value popped is less than the first, otherwise false.

  • 4 2 lt leaves false on the stack.
  • 2 4 lt leaves true on the stack.
  • 3 3 lt leaves false on the stack.

lte

Pops the top two values on the stack and pushes true if the second value popped is less than or equal to the first, otherwise false.

  • 4 2 lte leaves false on the stack.
  • 2 4 lte leaves true on the stack.
  • 3 3 lte leaves true on the stack.

gt

Pops the top two values on the stack and pushes true if the second value popped is greater than the first, otherwise false.

  • 4 2 gt leaves true on the stack.
  • 2 4 gt leaves false on the stack.
  • 3 3 gt leaves false on the stack.

gte

Pops the top two values on the stack and pushes true if the second value popped is greater than or equal to the first, otherwise false.

  • 4 2 gte leaves true on the stack.
  • 2 4 gte leaves false on the stack.
  • 3 3 gte leaves true on the stack.

eq

Pops the top two values on the stack and pushes true if the two values are equal, otherwise false.

  • 4 2 eq leaves false on the stack.
  • 2 4 eq leaves false on the stack.
  • 3 3 eq leaves true on the stack.

neq

Pops the top two values on the stack and pushes true if the two values are not equal, otherwise false.

  • 4 2 neq leaves true on the stack.
  • 2 4 neq leaves true on the stack.
  • 3 3 neq leaves false on the stack.

and

Pops the top two values on the stack and pushes true if both values are true, otherwise false.

  • true true and leaves true on the stack.
  • false true and leaves false on the stack.
  • false false and leaves false on the stack.

or

Pops the top two values on the stack and pushes true if either value is true, otherwise false.

  • true true or leaves true on the stack.
  • false true or leaves true on the stack.
  • false false or leaves false on the stack.

not

Pops the top value on the stack and pushes true if the value is false, otherwise true.

  • true not leaves false on the stack.
  • false not leaves true on the stack.

dup

Duplicates the top value on the stack and pushes it to the stack. 1 dup leaves 1 1 on the stack. "test string" dup leaves "test string" "test string" on the stack.

pop

Pops the top value on the stack. 1 pop leaves nothing on the stack.

print

Pops the top value on the stack and prints it. 1 print leaves nothing on the stack.

println

Pops the top value on the stack and prints it and a trailing newline. 1 println leaves nothing on the stack.

trace

Adds the top value on the stack to the tracelog along with a trailing newline. Does not pop it. 1 trace leaves 1 on the stack.

showtracelog

Prints the tracelog. Does not touch the stack.

cleartracelog

Clears the tracelog. Does not touch the stack.

Raylib-only version operators

@initwindow

Initializes raylib window. Pops three values: title (string), height (long), width (long).

  • 200 400 "test window" @initwindow initializes a window titled "test window" with a width of 200 and a height of 400.

@windowshouldclose

Pushes a boolean to the stack representing whether the window should close (the user has closed the window).

@closewindow

Closes the window.

@showcursor

Shows the cursor. @showcursor

@hidecursor

Hides the cursor.

@clearbackground

Pops RGBA (0-255 long) values off the stack and clears the background.

  • 200 150 100 255 @clearbackground clears the background with a color of 200 red, 150 green, 100 blue, and 255 alpha.

@begindrawing

Begins drawing (can only draw while drawing) and processes window input (like mouse clicks).

@enddrawing

Ends drawing.

@settargetfps

Sets target update frequency. Pops a long from the stack.

  • 60 @settargetfps makes the window target 60 updates per second.

@getrandomvalue

Returns a random long value within a range. Pops two longs from the stack and pushes one long to the stack.

  • -100 100 @getrandomvalue results in a random value between -100 and 100 on the stack. Put the lower number first.

@iskeypressed

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the key is pressed but not held (this is the first frame it has been down).

  • @key_a @iskeypressed pushes true to the stack if a was pressed.

@iskeydown

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the key is held down.

  • @key_a @iskeypressed pushes true to the stack if a was held.

@iskeyreleased

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the key was just released (first frame it has not been held down).

  • @key_a @iskeyreleased pushes true to the stack if a was released.

@iskeyup

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the key is not held down.

  • @key_a @iskeyup pushes true to the stack if a is not held down.

@getkeypressed

Pushes a long to the stack. Gets the latest key pressed.

  • @getkeypressed @key_a eq if "last key pressed was a" else "last key pressed was not a" endif println

@setexitkey

Pops a long from the stack. Sets the key that closes the program. Escape by default.

  • @key_a @setexitkey makes the a key close the program.

@ismousebuttonpressed

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the mouse button was pressed but not held (first frame it is pressed).

  • @mouse_left @ismousebuttonpressed pushes true if left mouse button was pressed.

@ismousebuttondown

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the mouse button is held down.

  • @mouse_left @ismousebuttondown pushes true if left mouse button is held.

@ismousebuttonreleased

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the mouse button was just released (first frame not held down).

  • @mouse_left @ismousebuttonreleased pushes true if left mouse button was released.

@ismousebuttonup

Pops a long from the stack and pushes a boolean to the stack. Pushes true if the mouse button is not held down.

  • @mouse_left @ismousebuttonup pushes true if the left mouse button is not held down.

@getmousex

Pushes the X coordinate of the mouse to the stack as a long.

@getmousey

Pushes the Y coordinate of the mouse to the stack as a long.

@getmousepos

Same as @getmousex @getmousey. Pushes X then Y coordinates of the mouse to the stack as longs.

@setmousepos

Pops the Y then the X position (longs) and sets the mouse position to those coordinates.

  • 150 250 @setmousepos moves the mouse to (150, 250)

@setmouseoffset

Pops the Y then the X offset (longs) and sets the mouse offset as specified.

  • 150 250 @setmouseoffset sets the mouse offset to (150, 250)

@setmousescale

Pops the Y then the X scale (doubles) and sets the mouse scale as specified.

  • 1.5 2.5 @setmousescale sets the mouse scale to (1.5, 2.5)

@getmousewheel

Pushes the mouse wheel movement to the stack as a long.

@drawpixel

Pops RGBA values (0-255 longs) then XY (longs) position. Draws the RGBA color at the XY position.

  • 10 20 200 150 100 255 @drawpixel draws the color #c89664ff (200, 150, 100, 255) at (10, 20).

@drawline

Pops RGBA values (0-255 longs), thickness (double), and then two XY positions (longs). Draws a line between the two positions of the given color and thickness.

  • 10 20 40 80 2.0 200 150 100 255 @drawline draws a #c89664ff (200, 150, 100, 255) line between (10, 20) and (40, 80) of thickness 2.0.

@drawcircle

Pops RGBA values (0-255 longs), radius (double) and an XY position (longs). Draws a circle at the XY position of the given color and radius.

  • 10 20 7.5 200 150 100 255 @drawcircle draws a #c89664ff (200, 150, 100, 255) circle of radius 7.5 at (10, 20).

@drawcirclelines

Same as @drawcircle but only draws the outline.

@drawellipse

Pops RGBA values (0-255 longs), XY radius (doubles) and an XY position (longs). Draws an ellipse at the XY position of the given color and radii.

@drawellipselines

Same as @drawellipse but only draws the outline.

@drawrectangle

Pops RGBA values (0-255 longs), width, height, and XY position (longs). XY position denotes the top left of the rectangle.

  • 10 15 20 25 200 150 100 255 @drawrectangle draws a #c89664ff (200, 150, 100, 255) rectangle 20 wide and 25 high with the top left corner at (10, 15).

@drawrectanglelines

Same as @drawrectangle but only draws the outline.

@drawtriangle (since 4e02b8b)

Pops RGBA values (0-255 longs) and 3 XY positions (longs).

  • 20 30 50 60 80 15 200 150 100 255 @drawtrirangle draws a #c89664ff (200, 150, 100, 255) triangle with vertices (20, 30), (50, 60), and (80, 15).

@drawtrianglelines (since 4e02b8b)

Same as @drawtriangle but only draws the outline.