Skip to content
This repository was archived by the owner on Jun 22, 2018. It is now read-only.

Language Reference

tripl3dogdare edited this page Aug 21, 2016 · 2 revisions

All of Subterra's instructions are documented here.

Command Effect Version Added
~ Turns everything after it until the end of a line into a comment.
0-9 Pushes an integer to the stack. (Note that 15 will push [15], not [1,5])
+-*/% Pops two integers off the stack and pushes the result of the corresponding math operation (using -, [6,2] -> [4]).
r Pops an integer from the stack and pushes a random number between 0 (inclusive) and that number (exclusive). v1.1
$ Pops the top of the stack and deletes it.
& Duplicates the top of the stack.
b Moves the top of the stack to the bottom.
t Moves the bottom of the stack to the top.
@ Reverses the entire stack.
s Pushes the size of the stack ([3,2,1] -> [3,2,1,3]).
e Empties the stack.
= Pops two elements and pushes whether they are equal.
! Pops two elements and pushes whether they are not equal.
< Pops two elements and pushes whether the lower is less than the upper.
> Pops two elements and pushes whether the lower is greater than the upper.
? Pops the top of the stack and executes the following subroutine if the resulting value is not 0.
: Can only be used after a ?; executes the following subroutine if the value was 0.
w Calls the following subroutine, then if it's return value is not 0 executes the second. Repeats until the first subroutine returns 0.
p Pops the top of the stack and prints it as an integer.
c Pops the top of the stack and prints it as a Unicode character.
i Waits for user input, then pushes it as a string (see Non-Integer Datatypes).
" Pushes everything between itself and the next " as a string (see Non-Integer Datatypes). Respects valid escape sequences prefixed with \ as standard ASCII characters.
' The same as "; can be used to avoid incessant escaping.
\ Pushes the Unicode value of the following character to the stack rather than executing it.
{[( Begins a subroutine definition (see Understanding Subroutines).
}]) Ends a subroutine definition (see Understanding Subroutines).
# Pops the top of the stack and calls the corresponding subroutine.
d Pushes the program's current recursion depth. Useful for preventing code from running when a module is imported (can be used analagously to Python's if __name__ == '__main__' by checking it against 0).
m Pops a string from the stack and imports the file at that path. See Import System for details.
. Calls an imported subroutine using the next two integers (respectively import ID and subroutine ID). See Import System for details.
Space, Tab, Newline, ` ;` Token seperators (i.e. 15 will push [15], where 1;5 will push [1,5]). Will be otherwise ignored.

Clone this wiki locally