print(x) -> any | output any value to the console (with linefeed). returns its argument. |
string(x) -> string | convert any value to string |
set_print_depth(depth:int) | for printing / string conversion: sets max vectors/objects recursion depth (default 10) |
set_print_length(len:int) | for printing / string conversion: sets max string length (default 10000) |
set_print_quoted(quoted:int) | for printing / string conversion: if the top level value is a string, whether to convert it with escape codes and quotes (default false) |
set_print_decimals(decimals:int) | for printing / string conversion: number of decimals for any floating point output (default -1, meaning all) |
getline() -> string | reads a string from the console if possible (followed by enter) |
if(cond, then:function [, else:function]) -> any | evaluates then or else depending on cond, else is optional |
while(cond:function, do:function) -> any | evaluates body while cond (converted to a function) holds true, returns last body value |
for(iter, do:function) | iterates over int/vector/string, body may take [ element [ , index ] ] arguments |
append(xs:[any], ys:[any]) -> [any] | creates a new vector by appending all elements of 2 input vectors |
vector_reserve(typeid:typeid, len:int) -> [any] | creates a new empty vector much like [] would, except now ensures it will have space for len push() operations without having to reallocate. pass "typeof return" as typeid. |
length(x:int) -> int | length of int (identity function, useful in combination with string/vector version) |
length(s:string) -> int | length of string |
length(s:xy_z_w_f) -> int | number of fields in a numerical struct |
length(s:xy_z_w_i) -> int | number of fields in a numerical struct |
length(xs:[any]) -> int | length of vector |
equal(a, b) -> int | structural equality between any two values (recurses into vectors/objects, unlike == which is only true for vectors/objects if they are the same object) |
push(xs:[any], x) -> [any] | appends one element to a vector, returns existing vector |
pop(xs:[any]) -> any | removes last element from vector and returns it |
top(xs:[any]) -> any | returns last element from vector |
replace(xs:xy_z_w_f, i:int, x:float) -> xy_z_w_f | returns a copy of a numeric struct with the element at i replaced by x |
replace(xs:xy_z_w_i, i:int, x:int) -> xy_z_w_i | returns a copy of a numeric struct with the element at i replaced by x |
replace(xs:[any], i:int, x) -> [any] | returns a copy of a vector with the element at i replaced by x |
insert(xs:[any], i:int, x) -> [any] | inserts a value into a vector at index i, existing elements shift upward, returns original vector |
remove(xs:[any], i:int [, n:int]) -> any | remove element(s) at index i, following elements shift down. pass the number of elements to remove as an optional argument, default 1. returns the first element removed. |
removeobj(xs:[any], obj) -> any | remove all elements equal to obj (==), returns obj. |
binarysearch(xs:[int], key:int) -> int, int | does a binary search for key in a sorted vector, returns as first return value how many matches were found, and as second the index in the array where the matches start (so you can read them, overwrite them, or remove them), or if none found, where the key could be inserted such that the vector stays sorted. This overload is for int vectors and keys. |
binarysearch(xs:[float], key:float) -> int, int | float version. |
binarysearch(xs:[string], key:string) -> int, int | string version. |
copy(xs) -> any | makes a shallow copy of any object. |
slice(xs:[any], start:int, size:int) -> [any] | returns a sub-vector of size elements from index start. start & size can be negative to indicate an offset from the vector length. |
any(xs:xy_z_w_i) -> int | returns wether any elements of the numeric struct are true values |
any(xs:[any]) -> int | returns wether any elements of the vector are true values |
all(xs:xy_z_w_i) -> int | returns wether all elements of the numeric struct are true values |
all(xs:[any]) -> int | returns wether all elements of the vector are true values |
substring(s:string, start:int, size:int) -> string | returns a substring of size characters from index start. start & size can be negative to indicate an offset from the string length. |
string2int(s:string) -> int | converts a string to an int. returns 0 if no numeric data could be parsed |
string2float(s:string) -> float | converts a string to a float. returns 0.0 if no numeric data could be parsed |
tokenize(s:string, delimiters:string, whitespace:string) -> [string] | splits a string into a vector of strings, by splitting into segments upon each dividing or terminating delimiter. Segments are stripped of leading and trailing whitespace. Example: "; A ; B C; " becomes [ "", "A", "B C" ] with ";" as delimiter and " " as whitespace. |
unicode2string(us:[int]) -> string | converts a vector of ints representing unicode values to a UTF-8 string. |
string2unicode(s:string) -> [int]? | converts a UTF-8 string into a vector of unicode values, or nil upon a decoding error |
number2string(number:int, base:int, minchars:int) -> string | converts the (unsigned version) of the input integer number to a string given the base (2..36, e.g. 16 for hex) and outputting a minimum of characters (padding with 0). |
lowercase(s:string) -> string | converts a UTF-8 string from any case to lower case, affecting only A-Z |
uppercase(s:string) -> string | converts a UTF-8 string from any case to upper case, affecting only a-z |
escapestring(s:string, set:string, prefix:string, postfix:string) -> string | prefixes & postfixes any occurrences or characters in set in string s |
concatstring(v:[string], sep:string) -> string | concatenates all elements of the string vector, separated with sep. |
pow(a:float, b:float) -> float | a raised to the power of b |
log(a:float) -> float | natural logaritm of a |
sqrt(f:float) -> float | square root |
ceiling(f:float) -> int | the nearest int >= f |
ceiling(v:xy_z_w_f) -> xy_z_w_i | the nearest ints >= each component of v |
floor(f:float) -> int | the nearest int <= f |
floor(v:xy_z_w_f) -> xy_z_w_i | the nearest ints <= each component of v |
int(f:float) -> int | converts a float to an int by dropping the fraction |
int(v:xy_z_w_f) -> xy_z_w_i | converts a vector of floats to ints by dropping the fraction |
round(f:float) -> int | converts a float to the closest int. same as int(f + 0.5), so does not work well on negative numbers |
round(v:xy_z_w_f) -> xy_z_w_i | converts a vector of floats to the closest ints |
fraction(f:float) -> float | returns the fractional part of a float: short for f - int(f) |
fraction(v:xy_z_w_f) -> xy_z_w_f | returns the fractional part of a vector of floats |
float(i:int) -> float | converts an int to float |
float(v:xy_z_w_i) -> xy_z_w_f | converts a vector of ints to floats |
sin(angle:float) -> float | the y coordinate of the normalized vector indicated by angle (in degrees) |
cos(angle:float) -> float | the x coordinate of the normalized vector indicated by angle (in degrees) |
tan(angle:float) -> float | the tangent of an angle (in degrees) |
sincos(angle:float) -> xy_f | the normalized vector indicated by angle (in degrees), same as [ cos(angle), sin(angle) ] |
arcsin(y:float) -> float | the angle (in degrees) indicated by the y coordinate projected to the unit circle |
arccos(x:float) -> float | the angle (in degrees) indicated by the x coordinate projected to the unit circle |
atan2(vec:xy_z_w_f) -> float | the angle (in degrees) corresponding to a normalized 2D vector |
radians(angle:float) -> float | converts an angle in degrees to radians |
degrees(angle:float) -> float | converts an angle in radians to degrees |
normalize(vec:xy_z_w_f) -> xy_z_w_f | returns a vector of unit length |
dot(a:xy_z_w_f, b:xy_z_w_f) -> float | the length of vector a when projected onto b (or vice versa) |
magnitude(v:xy_z_w_f) -> float | the geometric length of a vector |
manhattan(v:xy_z_w_i) -> int | the manhattan distance of a vector |
cross(a:xyz_f, b:xyz_f) -> xyz_f | a perpendicular vector to the 2D plane defined by a and b (swap a and b for its inverse) |
rnd(max:int) -> int | a random value [0..max). |
rnd(max:xy_z_w_i) -> xy_z_w_i | a random vector within the range of an input vector. |
rndfloat() -> float | a random float [0..1) |
rndseed(seed:int) | explicitly set a random seed for reproducable randomness |
div(a:int, b:int) -> float | forces two ints to be divided as floats |
clamp(x:int, min:int, max:int) -> int | forces an integer to be in the range between min and max (inclusive) |
clamp(x:float, min:float, max:float) -> float | forces a float to be in the range between min and max (inclusive) |
clamp(x:xy_z_w_i, min:xy_z_w_i, max:xy_z_w_i) -> xy_z_w_i | forces an integer vector to be in the range between min and max (inclusive) |
clamp(x:xy_z_w_f, min:xy_z_w_f, max:xy_z_w_f) -> xy_z_w_f | forces a float vector to be in the range between min and max (inclusive) |
inrange(x:int, range:int [, bias:int]) -> int | checks if an integer is >= bias and < bias + range. Bias defaults to 0. |
inrange(x:xy_z_w_i, range:xy_z_w_i [, bias:xy_z_w_i]) -> int | checks if a 2d/3d integer vector is >= bias and < bias + range. Bias defaults to 0. |
inrange(x:xy_z_w_f, range:xy_z_w_f [, bias:xy_z_w_f]) -> int | checks if a 2d/3d float vector is >= bias and < bias + range. Bias defaults to 0. |
abs(x:int) -> int | absolute value of an integer |
abs(x:float) -> float | absolute value of a float |
abs(x:xy_z_w_i) -> xy_z_w_i | absolute value of an int vector |
abs(x:xy_z_w_f) -> xy_z_w_f | absolute value of a float vector |
min(x:int, y:int) -> int | smallest of 2 integers. |
min(x:float, y:float) -> float | smallest of 2 floats. |
min(x:xy_z_w_i, y:xy_z_w_i) -> xy_z_w_i | smallest components of 2 int vectors |
min(x:xy_z_w_f, y:xy_z_w_f) -> xy_z_w_f | smallest components of 2 float vectors |
min(v:xy_z_w_i) -> int | smallest component of a int vector. |
min(v:xy_z_w_f) -> float | smallest component of a float vector. |
min(v:[int]) -> int | smallest component of a int vector, or INT_MAX if length 0. |
min(v:[float]) -> float | smallest component of a float vector, or FLT_MAX if length 0. |
max(x:int, y:int) -> int | largest of 2 integers. |
max(x:float, y:float) -> float | largest of 2 floats. |
max(x:xy_z_w_i, y:xy_z_w_i) -> xy_z_w_i | largest components of 2 int vectors |
max(x:xy_z_w_f, y:xy_z_w_f) -> xy_z_w_f | largest components of 2 float vectors |
max(v:xy_z_w_i) -> int | largest component of a int vector. |
max(v:xy_z_w_f) -> float | largest component of a float vector. |
max(v:[int]) -> int | largest component of a int vector, or INT_MIN if length 0. |
max(v:[float]) -> float | largest component of a float vector, or FLT_MIN if length 0. |
lerp(x:float, y:float, f:float) -> float | linearly interpolates between x and y with factor f [0..1] |
lerp(a:xy_z_w_f, b:xy_z_w_f, f:float) -> xy_z_w_f | linearly interpolates between a and b vectors with factor f [0..1] |
cardinalspline(z:xy_z_w_f, a:xy_z_w_f, b:xy_z_w_f, c:xy_z_w_f, f:float, tension:float) -> xyz_f | computes the position between a and b with factor f [0..1], using z (before a) and c (after b) to form a cardinal spline (tension at 0.5 is a good default) |
line_intersect(line1a:xy_f, line1b:xy_f, line2a:xy_f, line2b:xy_f) -> xy_f? | computes the intersection point between 2 line segments, or nil if no intersection |
circles_within_range(dist:float, positions:[xy_f], radiuses:[float], prefilter:[int]) -> [[int]] | given a vector of 2D positions (an same size vectors of radiuses and pre-filter), returns a vector of vectors of indices of the circles that are within dist of eachothers radius. pre-filter indicates objects that should appear in the inner vectors. |
resume(coroutine:coroutine [, returnvalue:any]) -> any | resumes execution of a coroutine, passing a value back or nil |
returnvalue(coroutine:coroutine) -> any | gets the last return value of a coroutine |
active(coroutine:coroutine) -> int | wether the given coroutine is still active |
hash(x:function) -> int | hashes a function value into an int |
hash(x) -> int | hashes any value into an int |
program_name() -> string | returns the name of the main program (e.g. "foo.lobster". |
vm_compiled_mode() -> int | returns if the VM is running in compiled mode (Lobster -> C++). |
seconds_elapsed() -> float | seconds since program start as a float, unlike gl_time() it is calculated every time it is called |
assert(condition) -> any | halts the program with an assertion failure if passed false. returns its input |
trace_bytecode(on:int, tail:int) | tracing shows each bytecode instruction as it is being executed, not very useful unless you are trying to isolate a compiler bug |
collect_garbage() -> int | forces a garbage collection to re-claim cycles. slow and not recommended to be used. instead, write code to clear any back pointers before abandoning data structures. Watch for a "LEAKS FOUND" message in the console upon program exit to know when you've created a cycle. returns number of objects collected. |
set_max_stack_size(max:int) | size in megabytes the stack can grow to before an overflow error occurs. defaults to 1 |
reference_count(val) -> int | get the reference count of any value. for compiler debugging, mostly |
set_console(on:int) | lets you turn on/off the console window (on Windows) |
command_line_arguments() -> [string] | |