lobster builtin functions:(file auto generated by compiler, do not modify)

builtin

print(x: string)output any value to the console (with linefeed).
string(x: string) -> stringconvert any value to string
set_print_depth(depth: int) -> intfor printing / string conversion: sets max vectors/objects recursion depth (default 10), returns old value
set_print_length(len: int) -> intfor printing / string conversion: sets max string length (default 100000), returns old value
set_print_quoted(quoted: bool) -> intfor printing / string conversion: if the top level value is a string, whether to convert it with escape codes and quotes (default false), returns old value
set_print_decimals(decimals: int) -> intfor printing / string conversion: number of decimals for any floating point output (default -1, meaning all), returns old value
set_print_indent(spaces: int) -> intfor printing / string conversion: number of spaces to indent with. default is 0: no indent / no multi-line, returns old value
get_line(prefix: string) -> stringreads a string from the console if possible (followed by enter). Prefix will be printed before the input
append(xs: [any], ys: [any]) -> [any]creates a new vector by appending all elements of 2 input vectors
append_into(dest: [any], src: [any]) -> [any]appends all elements of the second vector into the first
vector_capacity(xs: [any], len: int) -> [any]ensures the vector capacity (number of elements it can contain before re-allocating) is at least "len". Does not actually add (or remove) elements. This function is just for efficiency in the case the amount of "push" operations is known. returns original vector.
length(x: int) -> intlength of int (identity function, useful in combination with string/vector version)
length(s: string) -> intlength of string
length(xs: [any]) -> intlength of vector
equal(a: any, b: any) -> intstructural 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) -> [any]appends one element to a vector, returns existing vector
pop(xs: [any]) -> anyremoves last element from vector and returns it
top(xs: [any]) -> anyreturns last element from vector
insert(xs: [any], i: int, x: any) -> [any]inserts a value into a vector at index i, existing elements shift upward, returns original vector
remove(xs: [any], i: int) -> anyremove element at index i, following elements shift down. returns the element removed.
remove_range(xs: [any], i: int, n: int)remove n elements at index i, following elements shift down.
remove_obj(xs: [any], obj: any) -> anyremove all elements equal to obj (==), returns obj.
binary_search(xs: [int], key: int) -> int, intdoes 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.
binary_search(xs: [float], key: float) -> int, intfloat version.
binary_search(xs: [string], key: string) -> int, intstring version.
binary_search_object(xs: [any], key: any) -> int, intobject version. compares by reference rather than contents.
binary_search_first_field_string(xs: [any], key: string) -> int, intobject version where key is the first field (must be string, runtime error if it is not)
binary_search_first_field_object(xs: [any], key: any) -> int, intobject version where key is the first field (must be object, runtime error if it is not)
copy(x: any) -> anymakes a shallow copy of any object/vector/string.
deepcopy(x: any, depth: int) -> anymakes a deep copy of any object/vector/string. DAGs become trees, and cycles will clone until it reach the given depth. depth == 1 would do the same as copy.
slice(xs: [any], start: int, size: int) -> [any]returns a sub-vector of size elements from index start. size can be negative to indicate the rest of the vector.
any(xs: [any]) -> intreturns whether any elements of the vector are true values
any(xs: intN) -> intreturns whether any elements of the numeric struct are true values
all(xs: [any]) -> intreturns whether all elements of the vector are true values
all(xs: intN) -> intreturns whether all elements of the numeric struct are true values
substring(s: string, start: int, size: int) -> stringreturns a substring of size characters from index start. size can be negative to indicate the rest of the string.
find_string(s: string, substr: string, offset: int = 0) -> intfinds the index at which substr first appears, or -1 if none. optionally start at a position other than 0
find_string_reverse(s: string, substr: string, offset: int = 0) -> intfinds the index at which substr first appears when searching from the end, or -1 if none. optionally start at a position other than the end of the string
replace_string(s: string, a: string, b: string, count: int = 0) -> stringreturns a copy of s where all occurrences of a have been replaced with b. if a is empty, no replacements are made. if count is specified, makes at most that many replacements
string_to_int(s: string, base: int = 0) -> int, intconverts a string to an int given the base (2..36, e.g. 16 for hex, default is 10).returns 0 if no numeric data could be parsed; second return value is true if allcharacters of the string were parsed.
string_to_float(s: string) -> float, intconverts a string to a float. returns 0.0 if no numeric data could be parsed;second return value is true if all characters of the string were parsed.
tokenize(s: string, delimiters: string, whitespace: string, dividing: int = 0) -> [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. If dividing was true, there would be a 5th empty string element.
unicode_to_string(us: [int]) -> stringconverts a vector of ints representing unicode values to a UTF-8 string.
string_to_unicode(s: string) -> [int], intconverts a UTF-8 string into a vector of unicode values. second return value is false if there was a decoding error, and the vector will only contain the characters up to the error
number_to_string(number: int, base: int, minchars: int) -> stringconverts 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) -> stringconverts a UTF-8 string from any case to lower case, affecting only A-Z
uppercase(s: string) -> stringconverts a UTF-8 string from any case to upper case, affecting only a-z
escape_string(s: string, set: string, prefix: string, postfix: string) -> stringprefixes & postfixes any occurrences or characters in set in string s
concat_string(v: [string], sep: string) -> stringconcatenates all elements of the string vector, separated with sep.
repeat_string(s: string, n: int) -> stringreturns a string consisting of n copies of the input string.
pow(a: int, b: int) -> inta raised to the power of b, for integers, using exponentiation by squaring
pow(a: float, b: float) -> floata raised to the power of b
pow(a: floatN, b: float) -> floatNvector elements raised to the power of b
log(a: float) -> floatnatural logaritm of a
log2(a: float) -> floatbase 2 logaritm of a
sqrt(f: float) -> floatsquare root
ceiling(f: float) -> intthe nearest int >= f
ceiling(v: floatN) -> intNthe nearest ints >= each component of v
floor(f: float) -> intthe nearest int <= f
floor(v: floatN) -> intNthe nearest ints <= each component of v
int(f: float) -> intconverts a float to an int by dropping the fraction
int(v: floatN) -> intNconverts a vector of floats to ints by dropping the fraction
round(f: float) -> intconverts a float to the closest int
round(v: floatN) -> intNconverts a vector of floats to the closest ints
fraction(f: float) -> floatreturns the fractional part of a float: short for f - floor(f)
fraction(v: floatN) -> floatNreturns the fractional part of a vector of floats
float(i: int) -> floatconverts an int to float
float(v: intN) -> floatNconverts a vector of ints to floats
sin(angle: float) -> floatthe y coordinate of the normalized vector indicated by angle (in degrees)
sin(angle: floatN) -> floatNthe y coordinates of the normalized vector indicated by the angles (in degrees)
cos(angle: float) -> floatthe x coordinate of the normalized vector indicated by angle (in degrees)
cos(angle: floatN) -> floatNthe x coordinates of the normalized vector indicated by the angles (in degrees)
tan(angle: float) -> floatthe tangent of an angle (in degrees)
tan(angle: floatN) -> floatNthe tangents of the angles (in degrees)
sincos(angle: float) -> float2the normalized vector indicated by angle (in degrees), same as float2 { cos(angle), sin(angle) }
asin(y: float) -> floatthe angle (in degrees) indicated by the y coordinate projected to the unit circle
acos(x: float) -> floatthe angle (in degrees) indicated by the x coordinate projected to the unit circle
atan(x: float) -> floatthe angle (in degrees) indicated by the y coordinate of the tangent projected to the unit circle
radians(angle: float) -> floatconverts an angle in degrees to radians
degrees(angle: float) -> floatconverts an angle in radians to degrees
atan2(vec: float2) -> floatthe angle (in degrees) corresponding to a normalized 2D vector
radians(angle: float) -> floatconverts an angle in degrees to radians
degrees(angle: float) -> floatconverts an angle in radians to degrees
normalize(vec: floatN) -> floatNreturns a vector of unit length
dot(a: floatN, b: floatN) -> floatthe length of vector a when projected onto b (or vice versa)
magnitude(v: floatN) -> floatthe geometric length of a vector
magnitude_squared(v: floatN) -> floatthe geometric length of a vector squared
magnitude_squared(v: intN) -> intthe geometric length of a vector squared
manhattan(v: intN) -> intthe manhattan distance of a vector
cross(a: float3, b: float3) -> float3a perpendicular vector to the 2D plane defined by a and b (swap a and b for its inverse)
volume(v: floatN) -> floatthe volume of the area spanned by the vector
volume(v: intN) -> intthe volume of the area spanned by the vector
rnd(max: int) -> inta random value [0..max).
rnd(max: intN) -> intNa random vector within the range of an input vector.
rnd_float() -> floata random float [0..1)
rnd_gaussian() -> floata random float in a gaussian distribution with mean 0 and stddev 1
rnd_seed(seed: int)explicitly set a random seed for reproducable randomness
rndm(max: int) -> intdeprecated: old mersenne twister version of the above for backwards compat.
rndm_seed(seed: int)deprecated: old mersenne twister version of the above for backwards compat.
div(a: int, b: int) -> floatforces two ints to be divided as floats
clamp(x: int, min: int, max: int) -> intforces an integer to be in the range between min and max (inclusive)
clamp(x: float, min: float, max: float) -> floatforces a float to be in the range between min and max (inclusive)
clamp(x: intN, min: intN, max: intN) -> intNforces an integer vector to be in the range between min and max (inclusive)
clamp(x: floatN, min: floatN, max: floatN) -> floatNforces a float vector to be in the range between min and max (inclusive)
in_range(x: int, range: int, bias: int = 0) -> intchecks if an integer is >= bias and < bias + range. Bias defaults to 0.
in_range(x: float, range: float, bias: float = 0.000000) -> intchecks if a float is >= bias and < bias + range. Bias defaults to 0.
in_range(x: int2, range: int2, bias: int2 = nil) -> intchecks if a 2d integer vector is >= bias and < bias + range. Bias defaults to 0.
in_range(x: int3, range: int3, bias: int3 = nil) -> intchecks if a 3d integer vector is >= bias and < bias + range. Bias defaults to 0.
in_range(x: float2, range: float2, bias: float2 = nil) -> intchecks if a 2d float vector is >= bias and < bias + range. Bias defaults to 0.
in_range(x: float3, range: float3, bias: float3 = nil) -> intchecks if a 2d float vector is >= bias and < bias + range. Bias defaults to 0.
abs(x: int) -> intabsolute value of an integer
abs(x: float) -> floatabsolute value of a float
abs(x: intN) -> intNabsolute value of an int vector
abs(x: floatN) -> floatNabsolute value of a float vector
sign(x: int) -> intsign (-1, 0, 1) of an integer
sign(x: float) -> intsign (-1, 0, 1) of a float
sign(x: intN) -> intNsigns of an int vector
sign(x: floatN) -> intNsigns of a float vector
min(x: int, y: int) -> intsmallest of 2 integers.
min(x: float, y: float) -> floatsmallest of 2 floats.
min(x: intN, y: intN) -> intNsmallest components of 2 int vectors
min(x: floatN, y: floatN) -> floatNsmallest components of 2 float vectors
min(v: intN) -> intsmallest component of a int vector.
min(v: floatN) -> floatsmallest component of a float vector.
min(v: [int]) -> intsmallest component of a int vector, or INT_MAX if length 0.
min(v: [float]) -> floatsmallest component of a float vector, or FLT_MAX if length 0.
max(x: int, y: int) -> intlargest of 2 integers.
max(x: float, y: float) -> floatlargest of 2 floats.
max(x: intN, y: intN) -> intNlargest components of 2 int vectors
max(x: floatN, y: floatN) -> floatNlargest components of 2 float vectors
max(v: intN) -> intlargest component of a int vector.
max(v: floatN) -> floatlargest component of a float vector.
max(v: [int]) -> intlargest component of a int vector, or INT_MIN if length 0.
max(v: [float]) -> floatlargest component of a float vector, or FLT_MIN if length 0.
popcount(x: int) -> intnumber of bits set in an integer
lerp(x: float, y: float, f: float) -> floatlinearly interpolates between x and y with factor f [0..1]
lerp(a: floatN, b: floatN, f: float) -> floatNlinearly interpolates between a and b vectors with factor f [0..1]
spherical_lerp(a: float4, b: float4, f: float) -> float4spherically interpolates between a and b quaternions with factor f [0..1]
smoothmin(x: float, y: float, k: float) -> floatk is the influence range
smoothstep(x: float) -> floatinput must be in range 0..1, https://en.wikipedia.org/wiki/Smoothstep
smoothstep(a: float, b: float, f: float) -> floathermite interpolation between a and b by f [0..1], https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml
smootherstep(x: float) -> floatinput must be in range 0..1, https://en.wikipedia.org/wiki/Smoothstep
cardinal_spline(z: floatN, a: floatN, b: floatN, c: floatN, f: float, tension: float) -> floatNcomputes 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: float2, line1b: float2, line2a: float2, line2b: float2) -> int, float2computes if there is an intersection point between 2 line segments, with the point as second return value
circles_within_range(dist: float, positions: [float2], radiuses: [float], positions2: [float2], radiuses2: [float], gridsize: int2) -> [[int]]Given a vector of 2D positions (and same size vectors of radiuses), returns a vector of vectors of indices (to the second set of positions and radiuses) of the circles that are within dist of eachothers radius. If the second set are [], the first set is used for both (and the self element is excluded). gridsize optionally specifies the size of the grid to use for accellerated lookup of nearby points. This is essential for the algorithm to be fast, too big or too small can cause slowdown. Omit it, and a heuristic will be chosen for you, which is currently sqrt(num_circles) * 2 along each dimension, e.g. 100 elements would use a 20x20 grid. Efficiency wise this algorithm is fastest if there is not too much variance in the radiuses of the second set and/or the second set has smaller radiuses than the first.
wave_function_collapse(tilemap: [string], size: int2) -> [string], intreturns a tilemap of given size modelled after the possible shapes in the input tilemap. Tilemap should consist of chars in the 0..127 range. Second return value the number of failed neighbor matches, this should ideally be 0, but can be non-0 for larger maps. Simply call this function repeatedly until it is 0
hash(x: int) -> inthashes an int value into a positive int; may be the identity function
hash(x: any) -> inthashes any ref value into a positive int
hash(x: function) -> inthashes a function value into a positive int
hash(x: float) -> inthashes a float value into a positive int
hash(v: intN) -> inthashes a int vector into a positive int
hash(v: floatN) -> inthashes a float vector into a positive int
call_function_value(x: function)calls a void / no args function value.. you shouldn't need to use this, it is a demonstration of how native code can call back into Lobster
type_id(ref: any) -> intint uniquely representing the type of the given reference (object/vector/string/resource). this is the same as typeof, except dynamic (accounts for subtypes of the static type). useful to compare the types of objects quickly. specializations of a generic type will result in different ids.
type_string(ref: any) -> stringstring representing the type of the given reference (object/vector/string/resource)
type_element_string(v: [any]) -> stringstring representing the type of the elements of a vector
type_field_count(obj: any) -> intnumber of fields in an object, or 0 for other reference types
type_field_string(obj: any, idx: int) -> stringstring representing the type of a field in an object, or empty for other reference types
type_field_name(obj: any, idx: int) -> stringname of a field in an object, or empty for other reference types
type_field_value(obj: any, idx: int) -> stringstring representing the value of a field in an object, or empty for other reference types
program_name() -> stringreturns the name of the main program (e.g. "foo.lobster"), "" if running from lpak.
vm_compiled_mode() -> intreturns if the VM is running in compiled mode (Lobster -> C++), or false for JIT.
seconds_elapsed() -> floatseconds since program start as a float, unlike gl.time() it is calculated every time it is called
date_time(utc: bool = false) -> [int]a vector of integers representing date & time information (index with date_time.lobster). By default returns local time, pass true for UTC instead.
date_time_string(utc: bool = false) -> stringa string representing date & time information in the format: 'Www Mmm dd hh:mm:ss yyyy'. By default returns local time, pass true for UTC instead.
date_time_string_format(format: string, utc: bool = false) -> stringa string representing date & time information using a formatting string according to https://en.cppreference.com/w/cpp/chrono/c/strftime, for example "%Y_%m_%d_%H_%M_%S". By default returns local time, pass true for UTC instead.
date_time_build_info() -> stringa string representing information from when this program was compiled.
assert(condition: any) -> anyhalts the program with an assertion failure if passed false. returns its input. runtime errors like this will contain a stack trace if --runtime-stack-trace is on.
get_stack_trace() -> stringgets a stack trace of the current location of the program (needs --runtime-stack-trace) without actually stopping the program.
get_memory_usage(n: int) -> stringgets a text showing the top n object types that are using the most memory.
pass()does nothing. useful for empty bodies of control structures.
trace_bytecode(mode: int)tracing shows each bytecode instruction as it is being executed, not very useful unless you are trying to isolate a compiler bug. Mode is off(0), on(1) or tail only (2)
reference_count(val: any) -> intget the reference count of any value. for compiler debugging, mostly
set_console(on: bool)lets you turn on/off the console window (on Windows)
set_output_level(level: int)0 = debug, 1 = verbose, 2 = warn (default), 3 = error, 4 = program
set_exit_code(code: int)this will be returned when run as a console application
command_line_arguments() -> [string]
thread_information() -> int, intreturns the number of hardware threads, and the number of cores
is_worker_thread() -> intwhether the current thread is a worker thread
start_worker_threads(numthreads: int)launch worker threads
stop_worker_threads()only needs to be called if you want to stop the worker threads before the end of the program, or if you want to call start_worker_threads again. workers_alive will become false inside the workers, which should then exit.
workers_alive() -> intwhether workers should continue doing work. returns false after stop_worker_threads() has been called.
thread_write(struct: any)put this struct in the thread queue
thread_read(type: typeid(any)) -> any?get a struct from the thread queue. pass the typeof struct. blocks if no suchstructs available. returns struct, or nil if stop_worker_threads() was called
thread_check(type: typeid(any)) -> any?tests if a struct is available on the thread queue. pass the typeof struct. returns struct, or nil if none available, or if stop_worker_threads() was called
crash_test_cpp_nullptr_exception()only for testing crash dump functionality, don't use! :)

compiler

compile_run_code(code: string, args: [string]) -> string, string?compiles and runs lobster source, sandboxed from the current program (in its own VM). the argument is a string of code. returns the return value of the program as a string, with an error string as second return value, or nil if none. using parse_data(), two program can communicate more complex data structures even if they don't have the same version of struct definitions.
compile_run_file(filename: string, args: [string]) -> string, string?same as compile_run_code(), only now you pass a filename.

file

scan_folder(folder: string, rel: bool = false) -> [string]?, [int]?returns two vectors representing all elements in a folder, the first vector containing all names, the second vector containing sizes in bytes (or -1 if a directory). set rel use a relative path, default is absolute. Returns nil if folder couldn't be scanned.
read_file(file: string, textmode: int = 0) -> string?returns the contents of a file as a string, or nil if the file can't be found. you may use either \ or / as path separators
write_file(file: string, contents: string, textmode: int = 0, absolute_path: int = 0) -> intcreates a file with the contents of a string, returns false if writing wasn't possible
rename_file(old_file: string, new_file: string) -> intrenames a file, returns false if it wasn't possible
delete_file(file: string) -> intdeletes a file, returns false if it wasn't possible. Will search in all import dirs.
exists_file(file: string) -> intchecks whether a file exists.
launch_subprocess(commandline: [string], stdin: string = nil) -> int, stringlaunches a sub process, with optionally a stdin for the process, and returns its return code (or -1 if it couldn't launch at all), and any output
vector_to_buffer(vec: [any], width: int = 4) -> stringconverts a vector of ints/floats (or structs of them) to a buffer, where each scalar is written with "width" bytes (1/2/4/8, default 4). Returns nil if the type couldn't be converted. Uses native endianness.
ensure_size(string: string, size: int, char: int, extra: int = 0) -> stringensures a string is at least size characters. if it is, just returns the existing string, otherwise returns a new string of that size (with optionally extra bytes added), with any new characters set to char. You can specify a negative size to mean relative to the end, i.e. new characters will be added at the start.
write_int64_le(string: string, i: int, val: int) -> string, intwrites a value as little endian to a string at location i. Uses ensure_size to make the string twice as long (with extra 0 bytes) if no space. Returns new string if resized, and the index of the location right after where the value was written. The _back version writes relative to the end (and writes before the index)
write_int32_le(string: string, i: int, val: int) -> string, int(see write_int64_le)
write_int16_le(string: string, i: int, val: int) -> string, int(see write_int64_le)
write_int8_le(string: string, i: int, val: int) -> string, int(see write_int64_le)
write_float64_le(string: string, i: int, val: float) -> string, int(see write_int64_le)
write_float32_le(string: string, i: int, val: float) -> string, int(see write_int64_le)
write_int64_le_back(string: string, i: int, val: int) -> string, int(see write_int64_le)
write_int32_le_back(string: string, i: int, val: int) -> string, int(see write_int64_le)
write_int16_le_back(string: string, i: int, val: int) -> string, int(see write_int64_le)
write_int8_le_back(string: string, i: int, val: int) -> string, int(see write_int64_le)
write_float64_le_back(string: string, i: int, val: float) -> string, int(see write_int64_le)
write_float32_le_back(string: string, i: int, val: float) -> string, int(see write_int64_le)
write_substring(string: string, i: int, substr: string, nullterm: int) -> string, intwrites a substring into another string at i (see also write_int64_le)
write_substring_back(string: string, i: int, substr: string, nullterm: int) -> string, int
compare_substring(string_a: string, i_a: int, string_b: string, i_b: int, len: int) -> intreturns if the two substrings are equal (0), or a < b (-1) or a > b (1).
read_int64_le(string: string, i: int) -> int, intreads a value as little endian from a string at location i. The value must be within bounds of the string. Returns the value, and the index of the location right after where the value was read. The _back version reads relative to the end (and reads before the index)
read_int32_le(string: string, i: int) -> int, int(see read_int64_le)
read_int16_le(string: string, i: int) -> int, int(see read_int64_le)
read_int8_le(string: string, i: int) -> int, int(see read_int64_le)
read_uint64_le(string: string, i: int) -> int, intreads a value as little endian from a string at location i. The value must be within bounds of the string. Returns the value, and the index of the location right after where the value was read. The _back version reads relative to the end (and reads before the index)
read_uint32_le(string: string, i: int) -> int, int(see read_int64_le)
read_uint16_le(string: string, i: int) -> int, int(see read_int64_le)
read_uint8_le(string: string, i: int) -> int, int(see read_int64_le)
read_float64_le(string: string, i: int) -> float, int(see read_int64_le)
read_float32_le(string: string, i: int) -> float, int(see read_int64_le)
read_int64_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_int32_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_int16_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_int8_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_uint64_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_uint32_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_uint16_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_uint8_le_back(string: string, i: int) -> int, int(see read_int64_le)
read_float64_le_back(string: string, i: int) -> float, int(see read_int64_le)
read_float32_le_back(string: string, i: int) -> float, int(see read_int64_le)

flatbuffers

flatbuffers.field_int64(string: string, tablei: int, vo: int, def: int) -> intreads a flatbuffers field from a string at table location tablei, field vtable offset vo, and default value def. The value must be within bounds of the string. Returns the value (or default if the field was not present)
flatbuffers.field_int32(string: string, tablei: int, vo: int, def: int) -> int(see flatbuffers.field_int64)
flatbuffers.field_int16(string: string, tablei: int, vo: int, def: int) -> int(see flatbuffers.field_int64)
flatbuffers.field_int8(string: string, tablei: int, vo: int, def: int) -> int(see flatbuffers.field_int64)
flatbuffers.field_uint64(string: string, tablei: int, vo: int, def: int) -> intreads a flatbuffers field from a string at table location tablei, field vtable offset vo, and default value def. The value must be within bounds of the string. Returns the value (or default if the field was not present)
flatbuffers.field_uint32(string: string, tablei: int, vo: int, def: int) -> int(see flatbuffers.field_int64)
flatbuffers.field_uint16(string: string, tablei: int, vo: int, def: int) -> int(see flatbuffers.field_int64)
flatbuffers.field_uint8(string: string, tablei: int, vo: int, def: int) -> int(see flatbuffers.field_int64)
flatbuffers.field_float64(string: string, tablei: int, vo: int, def: float) -> float(see flatbuffers.field_int64)
flatbuffers.field_float32(string: string, tablei: int, vo: int, def: float) -> float(see flatbuffers.field_int64)
flatbuffers.field_string(string: string, tablei: int, vo: int) -> stringreads a flatbuffer string field, returns "" if not present
flatbuffers.field_vector_len(string: string, tablei: int, vo: int) -> intreads a flatbuffer vector field length, or 0 if not present
flatbuffers.field_vector(string: string, tablei: int, vo: int) -> intreturns a flatbuffer vector field element start, or 0 if not present
flatbuffers.field_table(string: string, tablei: int, vo: int) -> intreturns a flatbuffer table field start, or 0 if not present
flatbuffers.field_struct(string: string, tablei: int, vo: int) -> intreturns a flatbuffer struct field start, or 0 if not present
flatbuffers.field_present(string: string, tablei: int, vo: int) -> intreturns if a flatbuffer field is present (unequal to default)
flatbuffers.indirect(string: string, index: int) -> intreturns a flatbuffer offset at index relative to itself
flatbuffers.string(string: string, index: int) -> stringreturns a flatbuffer string whose offset is at given index
flatbuffers.binary_to_json(schemas: string, binary: string, includedirs: [string]) -> string, string?returns a JSON string generated from the given binary and corresponding schema.if there was an error parsing the schema, the error will be in the second returnvalue, or nil for no error
flatbuffers.json_to_binary(schema: string, json: string, includedirs: [string]) -> string, string?returns a binary flatbuffer generated from the given json and corresponding schema.if there was an error parsing the schema, the error will be in the second returnvalue, or nil for no error

parsedata

parse_data(typeid: typeid(any), stringdata: string) -> any?, string?parses a string containing a data structure in lobster syntax (what you get if you convert an arbitrary data structure to a string) back into a data structure. supports int/float/string/vector and classes. classes will be forced to be compatible with their current definitions, i.e. too many elements will be truncated, missing elements will be set to 0/nil if possible. useful for simple file formats. returns the value and an error string as second return value (or nil if no error)
flexbuffers_value_to_binary(val: any, max_nesting: int = 0, cycle_detection: bool = false) -> stringturns any reference value into a flexbuffer. max_nesting defaults to 100. cycle_detection is by default off (expensive)
flexbuffers_binary_to_value(typeid: typeid(any), flex: string) -> any?, string?turns a flexbuffer into a value
flexbuffers_binary_to_json(flex: string, field_quotes: bool, indent_string: string) -> string?, string?turns a flexbuffer into a JSON string. If indent_string is empty, will be a single line string
flexbuffers_json_to_binary(json: string, filename_for_errors: string = nil) -> string, string?turns a JSON string into a flexbuffer, second value is error, if any
lobster_value_to_binary(val: any) -> stringturns any reference value into a binary using a fast & compact Lobster native serialization format. this is intended for threads/networking, not for storage (since it is not readable by other languages). data structures participating must have been marked by attribute serializable. does not provide protection against cycles, use flexbuffers if that is a concern.
lobster_binary_to_value(typeid: typeid(any), bin: string) -> any?, string?turns binary created by lobster_value_to_binary back into a value

matrix

matrix.multiply(a: [float], b: [float]) -> [float]input matrices must be 4x4 elements
matrix.rotate_x(angle: float2) -> [float]
matrix.rotate_y(angle: float2) -> [float]
matrix.rotate_z(angle: float2) -> [float]
matrix.translation(trans: float3) -> [float]

graphics

gl.window(title: string, xs: int, ys: int, flags: int = 0, samples: int = 1) -> string?opens a window for OpenGL rendering. returns error string if any problems, nil otherwise. For flags, see modules/gl.lobster
gl.require_version(major: int, minor: int)Call this before gl.window to request a certain version of OpenGL context. Currently only works on win/nix, minimum is 3.2.
gl.load_materials(materialdefs: string, inline: int = 0, prefix: string = nil) -> string?loads an additional materials file (data/shaders/default.materials is already loaded by default by gl.window()). if inline is true, materialdefs is not a filename, but the actual materials. prefix will be added to all shader names allowing you to compile the same shaders multiple times. returns error string if any problems, nil otherwise.
gl.scissor(top_left: int2, size: int2) -> int2, int2Sets the scissor testing, so only the pixels in the given rectangle canbe written. Returns the previous value of the scissor rectangle.
gl.frame() -> intadvances rendering by one frame, swaps buffers, and collects new input events. returns false if the closebutton on the window was pressed
gl.shutdown()shuts down the OpenGL window. you only need to call this function if you wish to close it before the end of the program
gl.window_title(title: string) -> stringchanges the window title.
gl.window_min_max(dir: int)>0 to maximize, <0 to minimize or 0 to restore.
gl.fullscreen(mode: int)use window_init enum flags from gl module
gl.window_size(size: int2)
gl.visible() -> intchecks if the window is currently visible (not minimized, or on mobile devices, in the foreground). If false, you should not render anything, nor run the frame's code.
gl.cursor(on: bool) -> intdefault the cursor is visible, turn off for implementing FPS like control schemes. return whether it was on before this call.
gl.grab(on: bool) -> intgrabs the mouse when the window is active. return whether it's on.
gl.button(name: string) -> int, intreturns the number of frames a key/mousebutton/finger has been down. went down this frame: == 1, is already down: >= 1, not down: == 0. the second return value is the same, but for the up direction: went up this frame: == 1, is already up: >= 1, not up: == 0. it is possible both happen inside one frame, i.e. down==1 and up==1! for name, pass a string like mouse1/mouse2/mouse3/escape/space/up/down/a/b/f1/joy1 etc. mouse11 and on are additional fingers
gl.key_repeat(name: string) -> intreturns if a key was a key repeat (went down, or is down with a key repeat)
gl.start_text_input(pos: int2, size: int2)starts text input. unlike gl.button which gets you keyboard keys, this is for input of strings, that can deal with unicode IME etc. pos & size are a hint where the string being edited is being displayed, such that an IME can popup a box next to it, if needed.
gl.text_input_state() -> string, string, int, intreturns the string that has been input since text input started, followed by any candinate text (partial characters in case of IME editing), and the cursor & selection size for it
gl.set_text_input(text: string)overwrites the current text string being accumulated
gl.end_text_input()stops accumulating text input
gl.touchscreen() -> intwhether a you're getting input from a touch screen (as opposed to mouse & keyboard)
gl.dpi(screen: int) -> intthe DPI of the screen. always returns a value for screen 0, any other screens may return 0 to indicate the screen doesn't exist
gl.window_size() -> int2a vector representing the size (in pixels) of the window, changes when the user resizes
gl.mouse_pos(i: int) -> int2the current mouse/finger position in pixels, pass a value other than 0 to read additional fingers (for touch screens only if the corresponding gl.isdown is true)
gl.mouse_delta(i: int) -> int2number of pixels the mouse/finger has moved since the last frame. use this instead of substracting positions to correctly deal with lifted fingers and FPS mode (gl.cursor(0))
gl.local_mouse_pos(i: int) -> float2the current mouse/finger position local to the current transform (gl.translate etc) (for touch screens only if the corresponding gl.isdown is true)
gl.last_pos(name: string, down: int) -> int2position (in pixels) key/mousebutton/finger last went down (true) or up (false)
gl.local_last_pos(name: string, down: int) -> float2position (local to the current transform) key/mousebutton/finger last went down (true) or up (false)
gl.mousewheel_delta() -> intamount the mousewheel scrolled this frame, in number of notches
gl.joy_axis(i: int) -> floatthe current joystick orientation for axis i, as -1 to 1 value. this gives you raw joystick values, prefer to use controller_axis()
gl.controller_axis(i: int) -> floatthe current controller orientation for axis i, as -1 to 1 value. the axes are (from 0): leftx, lefty, rightx, righty, triggerleft, triggerright. down/right have positive values. make sure to call gl.init_controller_database()
gl.delta_time() -> floatseconds since the last frame, updated only once per frame
gl.delta_time_rolling(n: int) -> floatseconds since the last frame, updated only once per frame, as a rolling average over the last N frames (max 64)
gl.time() -> floatseconds since the start of the OpenGL subsystem, updated only once per frame (use seconds_elapsed() for continuous timing)
gl.last_time(name: string, down: int) -> floattime key/mousebutton/finger last went down (true) or up (false)
gl.clear(col: float4)clears the framebuffer (and depth buffer) to the given color
gl.color(col: float4) -> float4sets the current color, returns previous one
gl.polygon(vertlist: [floatN])renders a polygon using the list of points given. warning: gl.polygon creates a new mesh every time, gl.new_poly/gl.render_mesh is faster.
gl.rounded_rectangle(size: float2, segments: int, corner_ratio: float)renders a rounded rectangle, try segments 50, corner_ratio 0.2
gl.circle(radius: float, segments: int)renders a circle
gl.open_circle(radius: float, segments: int, thickness: float)renders a circle that is open on the inside. thickness is the fraction of the radius that is filled, try e.g. 0.2
gl.unit_cube(insideout: int = 0)renders a unit cube (0,0,0) - (1,1,1). optionally pass true to have it rendered inside out
gl.rotate_x(vec: float2)rotates the yz plane around the x axis, using a 2D vector normalized vector as angle
gl.rotate_y(angle: float2)rotates the xz plane around the y axis, using a 2D vector normalized vector as angle
gl.rotate_z(angle: float2)rotates the xy plane around the z axis (used in 2D), using a 2D vector normalized vector as angle
gl.translate(vec: floatN)translates the current coordinate system along a vector
gl.translate(vec: intN)translates the current coordinate system along a vector
gl.scale(factor: float)scales the current coordinate system using a numerical factor
gl.scale(factor: floatN)scales the current coordinate system using a vector
gl.origin() -> float2returns a vector representing the current transform origin in pixels. only makes sense in 2D mode (no gl.perspective called).
gl.scaling() -> float2returns a vector representing the current transform scale in pixels. only makes sense in 2D mode (no gl.perspective called).
gl.model_view_projection() -> [float]returns a vector representing the current model view projection matrix (16 elements)
gl.model_view() -> [float]returns a vector representing the current model view matrix (16 elements)
gl.projection() -> [float]returns a vector representing the current projection matrix (16 elements)
gl.push_model_view()save the current state of the model view matrix (gl.translate, gl.rotate etc)
gl.pop_model_view() -> intrestore a previous state of the model view matrix. returns false if none
gl.point_scale(factor: float)sets the current scaling factor for point sprites. this can be what the current gl.scale is, or different, depending on the desired visuals. the ideal size may also be FOV dependent.
gl.line_mode(on: int) -> intset line mode (true == on), returns previous mode
gl.cull_front(on: bool) -> intset culling front (true) or back (false), returns previous value.
gl.hit(vec: floatN, i: int) -> intwhether the mouse/finger is inside of the rectangle specified in terms of the current transform (for touch screens only if the corresponding gl.isdown is true). Only true if the last rectangle for which gl.hit was true last frame is of the same size as this one (allows you to safely test in most cases of overlapping rendering)
gl.rect(size: float2, centered: int = 0)renders a rectangle (0,0)..(1,1) (or (-1,-1)..(1,1) when centered), scaled by the given size.
gl.rect_tc_col(size: float2, tc: float2, tcsize: float2, cols: [float4])Like gl.rect renders a sized quad, but allows you to specify texture coordinates and optionally colors (empty list for all white). Slow.
gl.unit_square(centered: int = 0)renders a square (0,0)..(1,1) (or (-1,-1)..(1,1) when centered)
gl.line(start: floatN, end: floatN, thickness: float)renders a line with the given thickness
gl.perspective(fovy: float, znear: float, zfar: float, frame_buffer_size: int2 = nil, frame_buffer_offset: int2 = nil, nodepth: int = 0)changes from 2D mode (default) to 3D right handed perspective mode with vertical fov (try 60), far plane (furthest you want to be able to render, try 1000) and near plane (try 1). Optionally specify a framebuffer size to override the current gl.framebuffer_size
gl.ortho(rh: int = 0, depth: int = 0)changes back to 2D mode rendering with a coordinate system from (0,0) top-left to the screen size in pixels bottom right. this is the default at the start of a frame, use this call to get back to that after gl.perspective. Pass true to rh have (0,0) bottom-left instead. Pass true to depth to have depth testing/writing on.
gl.ortho3d(center: float3, extends: float3)sets a custom ortho projection as 3D projection.
gl.new_poly(positions: [floatN]) -> resource<mesh>creates a mesh out of a loop of points, much like gl.polygon. gl.line_mode determines how this gets drawn (fan or loop). automatically generates texcoords and normals. returns mesh id
gl.new_mesh(format: string, positions: [float3], colors: [float4], normals: [float3], texcoords1: [float2], texcoords2: [float2], indices: [int] = nil) -> resource<mesh>creates a new vertex buffer and returns an integer id (1..) for it. format must be made up of characters P (position), C (color), T (texcoord), N (normal). indices may be []. positions is obligatory. you may specify [] for any of the other attributes if not required by format, or to get defaults for colors (white) / texcoords (position x & y) / normals (generated from adjacent triangles).
gl.new_mesh_iqm(filename: string) -> resource<mesh>?load a .iqm file into a mesh, returns mesh or nil on failure to load.
gl.mesh_parts(m: resource<mesh>) -> [string]returns an array of names of all parts of mesh m (names may be empty)
gl.mesh_size(m: resource<mesh>) -> intreturns the number of verts in this mesh
gl.mesh_animations(m: resource<mesh>) -> [string]return names of animations
gl.mesh_animation_frames(m: resource<mesh>, name: string) -> int, int, floatgiven name, return animation's first frame, number of frames and framerate, or '-1, -1, 0.0' if name is invalid
gl.animate_mesh(m: resource<mesh>, frame: float)set the frame for animated mesh m
gl.animate_mesh_blend(m: resource<mesh>, frame1: float, frame2: float, blending: float)set the blending frames for animated mesh m
gl.render_mesh(m: resource<mesh>)renders the specified mesh
gl.save_mesh(m: resource<mesh>, name: string, format: int = 0) -> string?saves the mesh to a file in the specified format (ply by default). for other supported formats, see modules/gl.lobster. warning: when using iqm format, make sure vertex format is 'PNC', which is being used by meshgen and cubegen. returns error string if any problems, nil otherwise.
gl.mesh_pointsize(m: resource<mesh>, pointsize: float)sets the pointsize for this mesh. the mesh must have been created with indices = nil for point rendering to be used. you also want to use a shader that works with points, such as color_attr_particle.
gl.set_shader(shader: string)changes the current shader. shaders must reside in the shaders folder, builtin ones are: color / textured / phong
gl.set_shader(shader: resource<shader>)changes the current shader from a value received from gl.get_shader
gl.get_shader(shader: string) -> resource<shader>gets a shader by name, for use with gl.set_shader
gl.set_uniform(name: string, value: floatN) -> intset a uniform on the current shader. size of float vector must match size of uniform in the shader. returns false on error.
gl.set_uniform(name: string, value: float) -> intset a uniform on the current shader. uniform in the shader must be a single float. returns false on error.
gl.set_uniform(name: string, value: intN) -> intset a uniform on the current shader. size of int vector must match size of uniform in the shader. returns false on error.
gl.set_uniform(name: string, value: int) -> intset a uniform on the current shader. uniform in the shader must be a single int. returns false on error.
gl.set_uniform_array(name: string, value: [float4]) -> intset a uniform on the current shader. uniform in the shader must be an array of vec4. returns false on error.
gl.set_uniform_matrix(name: string, value: [float], morerows: bool = false) -> intset a uniform on the current shader. pass a vector of 4/6/9/12/16 floats to set a mat2/mat3x2/mat3/mat4x3/mat4 respectively. pass true for morerows to get mat2x3/mat3x4. returns false on error.
gl.update_buffer_object(value: string, ssbo: int, offset: int, existing: resource<bufferobject>, dyn: bool) -> resource<bufferobject>?creates a uniform buffer object ssbo indicates if you want a shader storage block instead. returns buffer resource or nil on error.
gl.bind_buffer_object(name: string, bo: resource<bufferobject>) -> intattaches an existing bo to the current shader at the given uniform block name. uniforms in the shader can be any type, as long as it matches the data layout in the string buffer. returns false for error.
gl.copy_buffer_object(source: resource<bufferobject>, destination: resource<bufferobject>, srcoffset: int, dstoffset: int, length: int)copies the source buffer object into the destination buffer object
gl.bind_mesh_to_compute(mesh: resource<mesh>, name: string)Bind the vertex data of a mesh to a SSBO binding of a compute shader. Pass a nil mesh to unbind.
gl.dispatch_compute(groups: int3)dispatches the currently set compute shader in groups of sizes of the specified x/y/z values.
gl.dump_shader(filename: string, stripnonascii: bool) -> intDumps the compiled (binary) version of the current shader to a file. Contents are driver dependent. On Nvidia hardware it contains the assembly version of the shader as text, pass true for stripnonascii if you're only interested in that part.
gl.blend(on: int) -> intchanges the blending mode (use blending constants from texture.lobster), returns old mode
gl.load_texture(name: string, textureformat: int = 0) -> resource<texture>?returns texture if succesfully loaded from file name, otherwise nil. see texture.lobster for texture format. If textureformat includes cubemap, will load 6 images with "_ft" etc inserted before the "." in the filename. Uses stb_image internally (see http://nothings.org/), loads JPEG Baseline, subsets of PNG, TGA, BMP, PSD, GIF, HDR, PIC.
gl.save_texture(tex: resource<texture>, filename: string, flip: bool = false) -> intsaves the texture in .png format, returns true if succesful
gl.set_primitive_texture(i: int, tex: resource<texture>)sets texture unit i to texture (for use with rect/circle/polygon/line)
gl.set_mesh_texture(mesh: resource<mesh>, part: int, i: int, texture: resource<texture>)sets texture unit i to texture for a mesh and part (0 if not a multi-part mesh)
gl.set_image_texture(i: int, tex: resource<texture>, level: int, accessflags: int = 0)sets image unit i to texture (for use with compute). optionally specify writeonly/readwrite flags.
gl.unbind_all_textures()unbinds all textures set thru any set texture calls. typically not needed to call this manually, but may sometimes be needed when reusing textures across draw/compute calls
gl.create_texture(matrix: [[float4]], textureformat: int = 0) -> resource<texture>creates a texture from a 2d array of color vectors. see texture.lobster for texture format. for a cubemap, pass an array that is 6x as big on x than y
gl.create_texture_single_channel(matrix: [[float]], textureformat: int = 0) -> resource<texture>creates a texture from a 2d array of float vectors. see texture.lobster for texture format. for a cubemap, pass an array that is 6x as big on x than y
gl.create_blank_texture(size: int3, textureformat: int = 0) -> resource<texture>creates a blank texture (for use as frame buffer or with compute shaders). see texture.lobster for texture format
gl.create_colored_texture(size: int3, color: float4, textureformat: int = 0) -> resource<texture>creates a colored texture (for use as frame buffer or with compute shaders). see texture.lobster for texture format
gl.texture_size(tex: resource<texture>) -> int2returns the size of a texture
gl.read_texture(tex: resource<texture>) -> string?read back RGBA texture data into a string or nil on failure
gl.generate_texture_mipmap(tex: resource<texture> = nil)generate mipmaps for the specified texture
gl.set_texture_flags(tex: resource<texture>, tf: int)change texture filter/wrap/clamp flags on an existing texture
gl.switch_to_framebuffer(tex: resource<texture> = nil, hasdepth: int = 0, multisampleformat: int = 0, resolvetex: resource<texture> = nil, depthtex: resource<texture> = nil) -> intswitches to a new framebuffer, that renders into the given texture. also allocates a depth buffer for it if depth is true. pass the multisample flags that was used for this texture. pass a resolve texture if the base texture is multisample. pass your own depth texture if desired. pass a nil texture to switch back to the original framebuffer. performance note: do not recreate texture passed in unless necessary.
gl.framebuffer_size() -> int2a vector representing the size (in pixels) of the framebuffer, according to the last call to gl.switch_to_framebuffer, or same as gl.window_size otherwise
gl.light(pos: float3, params: float2)sets up a light at the given position for this frame. make sure to call this after your camera transforms but before any object transforms (i.e. defined in "worldspace"). params contains specular exponent in x (try 32/64/128 for different material looks) and the specular scale in y (try 1 for full intensity)
gl.render_tiles(positions: [float2], tilecoords: [int2], mapsize: int2, sizes: [float], rotations: [float])Renders a list of tiles from a tilemap. Each tile rendered is 0.5 in radius (1x1 square around pos) unless the optional sizes vector is specified (may be empty). Positions may be anywhere. tilecoords are indices into the map (0..mapsize-1), mapsize is the amount of tiles in the texture. rotations are optional (may be empty, faster if not specified). Tiles may overlap, they are drawn in order. Before calling this, make sure to have the texture set and a textured shader. If you want tile to use top-left as position, wrap this call in gl.translate float2_h:
gl.debug_grid(num: int3, dist: float3, thickness: float)renders a grid in space for debugging purposes. num is the number of lines in all 3 directions, and dist their spacing. thickness of the lines in the same units
gl.screenshot(filename: string) -> intsaves a screenshot in .png format, returns true if succesful
gl.dropped_file() -> stringif a file was dropped on the window this frame, the filename, otherwise empty
gl.create_time_query() -> resource<timequery>creates a time query object used for profiling GPU events
gl.start_time_query(tq: resource<timequery> = nil)starts the time query
gl.stop_time_query(tq: resource<timequery> = nil) -> floatstops the time query and returns the result
gl.init_controller_database(filename: string) -> string?loads the controller database if you want your game to support controllers. typically the argument should be: pakfile "data/controllers/gamecontrollerdb.txt". returns error if something went wrong
gl.open_url(url: string) -> intOpens a URL in the system browser, returns true if successful

font

gl.set_font_name(filename: string) -> intsets a freetype/OTF/TTF font as current (and loads it from disk the first time). returns true if success.
gl.set_font_size(size: int, outlinesize: float = 0.000000, outlinecolor: float4 = nil) -> intsets the font for rendering into this fontsize (in pixels). caches into a texture first time this size is used, flushes from cache if this size is not used an entire frame. font rendering will look best if using 1:1 pixels (careful with gl.scale/gl.translate). an optional outlinesize will give the font an outline. make sure to call this every frame. returns true if success
gl.set_max_font_size(size: int)sets the max font size to render to bitmaps. any sizes specified over that by setfontsize will still work but cause scaled rendering. default 256
gl.get_font_size() -> intthe current font size
gl.get_outline_size() -> floatthe current font size
gl.text(text: string) -> stringrenders a text with the current font (at the current coordinate origin)
gl.text_size(text: string) -> int2the x/y size in pixels the given text would need
gl.get_glyph_name(i: int) -> stringthe name of a glyph index, or empty string if the font doesn't have names
gl.get_char_code(name: string) -> intthe char code of a glyph by specifying its name, or 0 if it can not be found (or if the font doesn't have names)

sound

play_wav(filename: string, loops: int = 0, prio: int = 0) -> intplays a sound defined by a wav file (RAW or MS-ADPCM, any bitrate other than 22050hz 16bit will automatically be converted on first load). the default volume is the max volume (1.0) loops is the number of repeats to play (-1 repeats endlessly, omit for no repeats). prio is the priority of the sound which determines whether it can be deleted or not in case of too many play function calls (defaults to 0) returns the assigned channel number (1..8) or 0 on error
load_wav(filename: string) -> intloads a sound the same way play_sound does, but ahead of playback, to avoid any delays later. returns false on error
play_sfxr(filename: string, loops: int = 0, prio: int = 0) -> intplays a synth sound defined by a .sfs file (use http://www.drpetter.se/project_sfxr.html to generate these). the default volume is the max volume (1.0) loops is the number of repeats to play (-1 repeats endlessly, omit for no repeats). prio is the priority of the sound which determines whether it can be deleted or not in case of too many play function calls (defaults to 0) returns the assigned channel number (1..8) or 0 on error
load_sfxr(filename: string) -> intloads a sound the same way play_sfxr does, but ahead of playback, to avoid any delays later. returns false on error
play_ogg(filename: string, loops: int = 0, prio: int = 0) -> intplays an ogg file. the default volume is the max volume (1.0) loops is the number of repeats to play (-1 repeats endlessly, omit for no repeats). prio is the priority of the sound which determines whether it can be deleted or not in case of too many play function calls (defaults to 0) returns the assigned channel number (1..8) or 0 on error
load_ogg(filename: string) -> intloads a sound the same way play_ogg does, but ahead of playback, to avoid any delays later. returns false on error
sound_status(channel: int) -> intprovides the status of the specified sound channel. returns -1 on error or if the channel does not exist, 0 if the channel is free, 1 if it is playing, and 2 if the channel is active but paused.
sound_halt(channel: int)terminates a specific sound channel.
sound_pause(channel: int)pauses the specified sound channel.
sound_resume(channel: int)resumes a sound that was paused.
sound_volume(channel: int, volume: float)sets the channel volume in the range 0..1.
sound_position(channel: int, vecfromlistener: float3, listenerfwd: float3, attnscale: float)sets the channel volume and panning according to sound in a game world relative to the listener.
sound_time_length(channel: int) -> floatreturns the length in seconds of the sound playing on this channel
text_to_speech(text: string)Queues up text for async text to speech output. Currently on: win32
text_to_speech_stop()Stops current text to speech output and clears queue
play_music(filename: string, loops: int = 0) -> intplays music in many common formats (WAV, MP3, OGG, etc.). the default volume is the max volume (1.0) loops is the number of repeats to play (-1 repeats endlessly, omit for no repeats). returns the music id or 0 on error
play_music_fade_in(filename: string, ms: int, loops: int = 0) -> intplays music while fading in over ms milliseconds. See play_music for more info.
play_music_cross_fade(old_mus_id: int, new_filename: string, ms: int, loops: int = 0) -> intcross-fades new music with existing music over ms milliseconds. See play_music for more info.
music_fade_out(mus_id: int, ms: int)fade out music over ms milliseconds.
music_halt(mus_id: int)stop music with the given id.
music_pause(mus_id: int)pause music with the given id.
music_resume(mus_id: int)resume music with the given id.
music_volume(mus_id: int, vol: float)set the music volume in the range 0..1.
music_is_playing(mus_id: int) -> intreturns whether the music with the given id has not yet finished. Paused music is still considered to be playing
music_set_general_volume(vol: float)set the general music volume in the range 0..1.

physics

ph.initialize(gravityvector: float2)initializes or resets the physical world, gravity typically [0, -10].
ph.create_box(position: float2, size: float2, offset: float2 = nil, rotation: float = 0.000000, attachto: resource<fixture> = nil) -> resource<fixture>creates a physical box shape in the world at position, with size the half-extends around the center, offset from the center if needed, at a particular rotation (in degrees). attachto is a previous physical object to attach this one to, to become a combined physical body.
ph.create_circle(position: float2, radius: float, offset: float2 = nil, attachto: resource<fixture> = nil) -> resource<fixture>creates a physical circle shape in the world at position, with the given radius, offset from the center if needed. attachto is a previous physical object to attach this one to, to become a combined physical body.
ph.create_polygon(position: float2, vertices: [float2], attachto: resource<fixture> = nil) -> resource<fixture>creates a polygon circle shape in the world at position, with the given list of vertices. attachto is a previous physical object to attach this one to, to become a combined physical body.
ph.dynamic(shape: resource<fixture>, on: bool)makes a shape dynamic (on = true) or not.
ph.set_linear_velocity(id: resource<fixture>, velocity: float2)sets the linear velocity of a shape's center of mass.
ph.apply_linear_impulse_to_center(id: resource<fixture>, impulse: float2)applies a linear impulse to a shape at its center of mass.
ph.set_color(id: resource<fixture>, color: float4)sets a shape (or nil for particles) to be rendered with a particular color.
ph.set_shader(id: resource<fixture>, shadername: string)sets a shape (or nil for particles) to be rendered with a particular shader.
ph.set_texture(id: resource<fixture>, tex: resource<texture>, texunit: int = 0)sets a shape (or nil for particles) to be rendered with a particular texture (assigned to a texture unit, default 0).
ph.get_position(id: resource<fixture>) -> float2gets a shape's position.
ph.get_mass(id: resource<fixture>) -> floatgets a shape's mass.
ph.create_particle(position: float2, velocity: float2, color: float4, flags: int = 0) -> intcreates an individual particle. For flags, see include/physics.lobster
ph.create_particle_circle(position: float2, radius: float, color: float4, flags: int = 0)creates a circle filled with particles. For flags, see include/physics.lobster
ph.initialize_particles(radius: float)initializes the particle system with a given particle radius.
ph.step(seconds: float, viter: int, piter: int)simulates the physical world for the given period (try: gl.delta_time()). You can specify the amount of velocity/position iterations per step, more means more accurate but also more expensive computationally (try 8 and 3).
ph.particle_contacts(id: resource<fixture>) -> [int]gets the particle indices that are currently contacting a giving physics object. Call after step(). Indices may be invalid after next step().
ph.raycast(p1: float2, p2: float2, n: int) -> [int]returns a vector of the first n particle ids that intersect a ray from p1 to p2, not including particles that overlap p1.
ph.delete_particle(i: int)deletes given particle. Deleting particles causes indices to be invalidated at next step().
ph.getparticle_position(i: int) -> float2gets a particle's position.
ph.render()renders all rigid body objects.
ph.render_particles(scale: float)render all particles, with the given scale.

noise

simplex(pos: floatN, octaves: int, scale: float, persistence: float) -> floatreturns a simplex noise value [-1..1] given a 2D/3D or 4D location, the number of octaves (try 8), a scale (try 1), and persistence from one octave to the next (try 0.5)
simplex_raw(pos: floatN) -> floatreturns a simplex noise value [-1..1] given a 2D/3D or 4D location

meshgen

mg.sphere(radius: float)a sphere
mg.cube(extents: float3)a cube (extents are size from center)
mg.cylinder(radius: float, height: float)a unit cylinder (height is from center)
mg.tapered_cylinder(bot: float, top: float, height: float)a cyclinder where you specify the top and bottom radius (height is from center)
mg.superquadric(exponents: float3, scale: float3)a super quadric. specify an exponent of 2 for spherical, higher values for rounded squares
mg.superquadric_non_uniform(posexponents: float3, negexponents: float3, posscale: float3, negscale: float3)a superquadric that allows you to specify exponents and sizes in all 6 directions independently for maximum modelling possibilities
mg.supertoroid(R: float, exponents: float3)a super toroid. R is the distance from the origin to the center of the ring.
mg.landscape(zscale: float, xyscale: float)a simplex landscape of unit size
mg.set_polygon_reduction(polyreductionpasses: int, epsilon: float, maxtricornerdot: float)controls the polygon reduction algorithm. set polyreductionpasses to 0 for off, 100 for max compression, or low values for generation speed or to keep the mesh uniform. epsilon determines how flat adjacent triangles must be to be reduced, use 0.98 as a good tradeoff, lower to get more compression. maxtricornerdot avoid very thin triangles, use 0.95 as a good tradeoff, up to 0.99 to get more compression
mg.set_color_noise(noiseintensity: float, noisestretch: float)applies simplex noise to the colors of the model. try 0.3 for intensity. stretch scales the pattern over the model
mg.set_vertex_randomize(factor: float)randomizes all verts produced to give a more organic look and to hide the inherent messy polygons produced by the algorithm. try 0.15. note that any setting other than 0 will likely counteract the polygon reduction algorithm
mg.set_point_mode(on: bool)generates a point mesh instead of polygons
mg.polygonize(subdiv: int) -> resource<mesh>returns a generated mesh from past mg commands. subdiv determines detail and number of polygons (relative to the largest dimension of the model), try 30.. 300 depending on the subject. values much higher than that will likely make you run out of memory (or take very long).
mg.convert_to_cubes(subdiv: int, zoffset: int) -> resource<voxels>returns a cubegen block (see cg_ functions) from past mg commands. subdiv determines detail and number of cubes (relative to the largest dimension of the model).
mg.translate(vec: float3)translates the current coordinate system along a vector
mg.scale(f: float)scales the current coordinate system by the given factor
mg.scale_vec(vec: float3)non-unimformly scales the current coordinate system using individual factors per axis
mg.rotate(axis: float3, angle: float)rotates using axis/angle
mg.color(color: float4)sets the color, where an alpha of 1 means to add shapes to the scene (union), and 0 substracts them (carves)
mg.smooth(smooth: float)sets the smoothness in terms of the range of distance from the shape smoothing happens, defaults to 1.0
mg.push_transform()save the current state of the transform
mg.pop_transform()restore a previous state of the transform

cubegen

cg.init(size: int3) -> resource<voxels>initializes a new, empty 3D cube block. 1 byte per cell, careful with big sizes :) returns the block
cg.size(block: resource<voxels>) -> int3returns the current block size
cg.name(block: resource<voxels>) -> stringreturns the current block name
cg.offset(block: resource<voxels>) -> int3returns the current block offset
cg.set(block: resource<voxels>, pos: int3, size: int3, paletteindex: int)sets a range of cubes to palette index. index 0 is considered empty space.Coordinates automatically clipped to the size of the grid
cg.get(block: resource<voxels>, pos: int3) -> intsets a range of cubes to palette index. index 0 is considered empty space.Coordinates automatically clipped to the size of the grid
cg.copy(block: resource<voxels>, pos: int3, size: int3, dest: int3, flip: int3)copy a range of cubes from pos to dest. flip can be 1 (regular copy), or -1 (mirror)for each component, indicating the step from dest. Coordinates automatically clipped to the size of the grid
cg.blit(dst: resource<voxels>, src: resource<voxels>, dst_pos: int3, src_pos: int3, size: int3, flip: int3)copy a range of solid cubes from src to dst starting at src_pos and dst_pos, respectively. flip can be 1 (regular copy), or -1 (mirror)for each component, indicating the step from dest. Coordinates automatically clipped to the size of the grids
cg.clone(block: resource<voxels>, pos: int3, size: int3) -> resource<voxels>clone a range of cubes from pos to a new block. Coordinates automatically clipped to the size of the grid
cg.color_to_palette(block: resource<voxels>, color: float4) -> intconverts a color to a palette index. alpha < 0.5 is considered empty space. note: this is fast for the default palette, slow otherwise.
cg.palette_to_color(block: resource<voxels>, paletteindex: int) -> float4converts a palette index to a color. empty space (index 0) will have 0 alpha
cg.get_palette(world: resource<voxels>) -> int
cg.set_palette(world: resource<voxels>, palette_idx: int)
cg.load_palette(act_palette_file: string) -> int
cg.new_palette(palette: [float4]) -> intCreate a new palette from 256 float4 color values.
cg.get_palette_color(palette_idx: int, entry: int) -> float4
cg.remove_all_palettes()Remove all cached palettes to free up memory. WARNING: existing models will no longer render correctly. You generally only want to do this if you know that none of the existing models are needed.
cg.sample_down(scale: int, world: resource<voxels>)
cg.scale_up(scale: int, world: resource<voxels>) -> resource<voxels>
cg.stretch(newsize: int3, world: resource<voxels>) -> resource<voxels>
cg.create_mesh(block: resource<voxels>) -> resource<mesh>converts block to a mesh
cg.create_3d_texture(block: resource<voxels>, textureformat: int, monochrome: int = 0) -> resource<texture>returns the new texture, for format, pass flags you want in addition to 3d|single_channel|has_mips
cg.load_vox(name: string, material_palette: bool = false, file_contents: string = nil, remap_palettes: bool = false) -> [resource<voxels>], string?loads a .vox file (supports both MagicaVoxel or VoxLap formats). if material_palette is true the alpha channel will contain material flags. if file_contents is non-nil, it contains the file already loaded. if remap_palettes is true, then the palette will be remapped to match the MagicaVoxel UI if necessary. returns vector of blocks or empty if file failed to load, and error string if any
cg.load_vox_names(name: string) -> [string], string?loads a MagicaVoxel .vox file, and returns its contained sub model names.
cg.save_vox(block: resource<voxels>, name: string) -> intsaves a file in the .vox format (MagicaVoxel). returns false if file failed to save. this format can only save blocks <= 256^3, will fail if bigger
cg.chunks_skipped(block: resource<voxels>) -> int
cg.get_buf(block: resource<voxels>) -> stringreturns the data as a string of all palette indices, in z-major order
cg.average_surface_color(world: resource<voxels>) -> float3, int, int, int3, int3
cg.average_face_colors(world: resource<voxels>) -> [float]returns a vector of 8 elements with 4 floats per face: color and alpha.last element contains the total average color and the average + max alpha in the last channel
cg.num_solid(world: resource<voxels>) -> int
cg.rotate(block: resource<voxels>, n: int) -> resource<voxels>returns a new block rotated by n 90 degree steps from the input
cg.simplex(block: resource<voxels>, pos: int3, size: int3, spos: float3, ssize: float3, octaves: int, scale: float, persistence: float, solidcol: int, zscale: float, zbias: float)
cg.bounding_box(world: resource<voxels>, minsolids: float) -> int3, int3
cg.randomize(world: resource<voxels>, rnd_range: int, cutoff: int, paletteindex: int, filter: int)
cg.erode(world: resource<voxels>, minsolid: int, maxsolid: int) -> resource<voxels>
cg.normal_indices(block: resource<voxels>, radius: int) -> resource<voxels>creates a new block with normal indices based on voxel surface shape.the indices refer to the associated pallette.empty voxels will have a 0 length normal.2 is a good radius that balances speed/quality, use 1 for speed, 3 for max quality
cg.load_image(name: string, depth: int, edge: int, numtiles: int2) -> [resource<voxels>]loads an image file (same formats as gl.load_texture) and turns it into blocks. returns blocks or [] if file failed to load
cg.palette_storage_index(block: resource<voxels>) -> int
cg.get_palette_storage_len() -> int
cg.get_palette_storage_buf() -> string

vr

vr.init() -> intinitializes VR mode. returns true if a hmd was found and initialized
vr.start_eye(isright: int, znear: float, zfar: float)starts rendering for an eye. call for each eye, followed by drawing the world as normal. replaces gl.perspective
vr.start()starts VR by updating hmd & controller poses
vr.finish()finishes vr rendering by compositing (and distorting) both eye renders to the screen
vr.set_eye_texture(unit: int, isright: int)sets the texture for an eye (like gl.set_primitive_texture). call after vr.finish. can be used to render the non-VR display
vr.num_motion_controllers() -> intreturns the number of motion controllers in the system
vr.motioncontrollerstracking(n: int) -> intreturns if motion controller n is tracking
vr.motion_controller(n: int)sets up the transform ready to render controller n. if there is no controller n (or it is currently not tracking) the identity transform is used
vr.create_motion_controller_mesh(n: int) -> resource<mesh>?returns the mesh for motion controller n, or nil if not available
vr.motion_controller_button(n: int, button: string) -> intreturns the button state for motion controller n. isdown: >= 1, wentdown: == 1, wentup: == 0, isup: <= 0. buttons are: system, menu, grip, trigger, touchpad
vr.motion_controller_vec(n: int, i: int) -> float3returns one of the vectors for motion controller n. 0 = left, 1 = up, 2 = fwd, 4 = pos. These are in Y up space.
vr.hmd_vec(i: int) -> float3returns one of the vectors for hmd pose. 0 = left, 1 = up, 2 = fwd, 4 = pos. These are in Y up space.

steam

steam.init(appid: int, allowscreenshots: bool, initrelay: bool) -> intinitializes SteamWorks. returns 1 if succesful, 0 on failure. Specify a non-0 appid if you want to restart from steam if this wasn't started from steam (the return value in this case will be -1 to indicate you should terminate this instance). If you don't specify an appid here or in steam_appid.txt, init will likely fail. The other functions can still be called even if steam isn't active. allowscreenshots automatically uploads screenshots to steam (triggered by steam). initrelay initializes the relay network for p2p early, to save time when it is first used.
steam.shutdown()
steam.overlay() -> intreturns true if the steam overlay is currently on (you may want to auto-pause if so)
steam.username() -> stringreturns the name of the steam user, or empty string if not available.
steam.unlock_achievement(achievementname: string) -> intUnlocks an achievement and shows the achievement overlay if not already achieved before. Will also Q-up saving achievement to Steam. Returns true if succesful.
steam.write_file(file: string, contents: string) -> intwrites a file with the contents of a string to the steam cloud, or local storage if that fails, returns false if writing wasn't possible at all
steam.read_file(file: string) -> string?returns the contents of a file as a string from the steam cloud if available, or otherwise from local storage, or nil if the file can't be found at all.
steam.update()you must call this function in your game loop when using most steam APIs
steam.get_steam_id() -> intget the steam id of the current user
steam.friend_get_username(steam_id: int) -> stringreturns the name for the given steam id; this only works for friends, or users in the same lobby, chat room, game server, etc.
steam.net_identity() -> stringreturns the steam identity for this user. This same ID will be used for connecting to peers, sending messages, etc.
steam.net_identity_from_steam_id(steam_id: int) -> stringreturns a network identity for the given steam id
steam.net_identity_ipaddr() -> stringreturns the steam identity for this user, but as an IP address instead of a Steam ID. This can be useful when connecting two clients that are using the same Steam ID (e.g. on the same computer). NOTE: this will only work if p2p_listen_ipaddr is called first.
steam.p2p_set_send_buffer_size(size: int) -> intset the upper limit of pending bytes to be sent
steam.p2p_set_recv_buffer_size(size: int)upper limit on total size in bytes of received messages that will be buffered waiting to be processed by the application
steam.p2p_get_connection_status(ident: string) -> int, float, float, float, float, float, float, int, int, int, int, intreceive realtime connection status info. Returned values are: ping, local quality, remote quality, out packets/sec, out bytes/sec, in packets/sec, in bytes/sec, send rate bytes/sec, pending unreliable packets, pending reliable packets, sent unACKed reliable packets, and queue time in usec. See ISteamNetworkingSockets::GetConnectionRealTimeStatus() for more info.
steam.p2p_listen() -> intopen a listen socket to receive new connections
steam.p2p_listen_ipaddr(ipaddr: string) -> intopen a listen socket for receive new IP address connections
steam.p2p_close_listen() -> intclose the listen socket and stop accepting new connections
steam.p2p_connect(ident: string) -> intconnect to a user with a given steam identity (e.g. "steam:XXXX") or ip address (e.g. "ip:127.0.0.1:5105") that has opened a listen socket
steam.p2p_connect_ipaddr(ipaddr: string) -> intconnect to a user with a given IP address that has opened a listen socket
steam.p2p_close_connection(ident: string, linger: bool) -> intclose a connection opened with p2p_connect(); if linger is true then the connection will remain open for a short time to finish pending messages
steam.p2p_get_connections() -> [string]get a list of the steam identites that are currently connected
steam.p2p_rename_peer(ident: string, new_ident: string) -> intuse a different identifier for this peer. This can be useful when connecting multiple users using peer-to-peer, so you can have all peers in the network use the listen socket IP address and port as the identifier.
steam.p2p_send_message(ident: string, data: string, reliable: bool) -> intsend a reliable message to a given steam identity
steam.p2p_broadcast_message(data: string, reliable: bool) -> intsend a reliable message to all connected peers
steam.p2p_receive_messages() -> [string], [string]receive messages from all connected peers. The first return value is an array of messages, the second return value is an array of the steam identities that sent each message
steam.lobby_create(max_members: int) -> intcreate a new lobby that allows at most a given number of members; this lobby will be automatically joined. use lobby_get_created() to get the newly created lobby's steam id
steam.lobby_get_created() -> intget the steam id of the most recently created lobby
steam.lobby_join(steam_id: int) -> intjoin a lobby with the given steam id
steam.lobby_leave(steam_id: int) -> intleave a lobby with the given steam id
steam.lobby_set_joinable(steam_id: int, joinable: bool) -> intmark a lobby as joinable; only works if you are the owner
steam.lobby_get_joined() -> intget a list of the most recent lobby joined with lobby_create() or lobby_join()
steam.lobby_get_all_joined() -> [int]get a list of all of the lobbies that have been joined with lobby_create() or lobby_join()
steam.lobby_request_data(steam_id: int) -> intrefresh data for a given lobby; it is not necessary to call this for any lobby that you have joined
steam.lobby_get_data(steam_id: int, key: string) -> stringget the matching value for a given key stored on this lobby; if the key has not been set then the result is an empty string
steam.lobby_get_all_data(steam_id: int) -> [string], [string]get all key-value pairs stored on this lobby
steam.lobby_set_data(steam_id: int, key: string, value: string) -> intset a key-value pair for this lobby; only works if you are the owner
steam.lobby_delete_data(steam_id: int, key: string) -> intdelete a key-value pair for this lobby; only works if you are the owner
steam.lobby_get_num_members(steam_id: int) -> intget the number of members in this lobby
steam.lobby_get_members(steam_id: int) -> [int]get the steam ids of all members in this lobby; only works if you have joined the lobby
steam.lobby_request_add_numerical_filter(key: string, value: int, cmp: int) -> intadd a numerical filter for the next lobby request
steam.lobby_request_add_string_filter(key: string, value: string, cmp: int) -> intadd a string filter for the next lobby request
steam.lobby_request_add_result_count_filter(count: int) -> intadd a result count limit for the next lobby request
steam.lobby_request_list() -> intrequest a list of lobbies that match the current set of filters; this function completes asynchronously, call lobby_request_is_ready() to determine when it is ready and lobby_request_get_lobbies() to get the results
steam.lobby_request_list_reset()clear the list of matched lobbies, so lobby_request_is_ready() returns false
steam.lobby_request_is_ready() -> intreturns true when a call to lobby_request_list() has finished
steam.lobby_request_get_lobbies() -> [int]returns the list of matched lobbies when lobby_request_list() has finished
steam.lobby_get_game_server(lobby_id: int) -> intget the game server associated with this lobby
steam.lobby_set_game_server(lobby_id: int, server_id: int) -> intset the game server associated with this lobby; only works if you are the owner

imgui

im.init(dark_style: bool = false, flags: int = 0, rounding: float = 0.000000, border: float = 0.000000)
im.add_font(font_path: string, size: float, glyph_ranges: string = nil) -> intglyph_ranges will activate additional unicode ranges to be rasterized, and can be Default (most European languages), SimplifiedChinese, Japanese, Korean, Cyrillic, Thai, Vietnamese, Greek, ..
im.set_style_color(i: int, color: float4)
im.set_style_spacing(spacing: float2)
im.set_style_inner_spacing(spacing: float2)
im.set_style_window_padding(spacing: float2)
im.set_style_frame_padding(spacing: float2)
im.frame_start()(use im.frame instead)
im.frame_end()
im.dockspace_over_viewport()
im.window_demo() -> int
im.window_start(title: string, flags: int, dock: int)(use im.window instead)
im.window_end()
im.next_window_size(size: float2, cond: int)size in pixels
im.next_window_pos(pos: float2, pivot: float2, cond: int)pos in pixels, pivot values 0..1 relative to pos
im.button(label: string, size: float2 = nil) -> int
im.selectable(label: string, selected: bool = false) -> int
im.same_line()
im.new_line()
im.separator()
im.is_item_deactivated_after_edit() -> intreturns true if the last item was made inactive and made a value change when it was active
im.want_capture_mouse() -> intreturns true if imgui wants to capture the mouse
im.get_layout_pos() -> float2
im.set_layout_pos(pos: float2)
im.get_layout_screen_pos() -> float2
im.set_layout_screen_pos(pos: float2)
im.get_content_region_avail() -> float2returns the amount of space left in the current region from the cursor pos
im.calc_text_size(text: string) -> float2returns the amount of space used by the given text in the current font
im.mouse_clicked(button: int) -> intreturns whether the given mouse button was clicked anywhere
im.text(label: string)
im.text_wrapped(label: string)
im.font_start(font_idx: int)(use im.font instead)
im.font_end()
im.color_start(color: float4)(use im.color instead)
im.color_end()
im.tooltip(label: string)
im.tooltip_multi_start() -> int(use im.tooltip_multi instead)
im.tooltip_multi_end()
im.checkbox(label: string, bool: int) -> int
im.input_text(label: string, str: string) -> string
im.input_text_multi_line(label: string, str: string, num_lines: int) -> string
im.input_int(label: string, val: int, min: int, max: int) -> int
im.input_int(label: string, val: int) -> int
im.input_float(label: string, val: float) -> float
im.radio(labels: [string], active: int, horiz: int) -> intactive to select which one is activated, -2 for last frame's selection or 0
im.progress_bar(fraction: float, size: float2, overlay: string)display progress bar filled up to the given fraction. size.x < 0 to use all available space, size.x > 0 for a specific pixel width
im.combo(label: string, labels: [string], active: int) -> intactive to select which one is activated, -2 for last frame's selection or 0
im.listbox(label: string, labels: [string], active: int, height: int) -> intactive to select which one is activated, -1 for no initial selection, -2 for last frame's selection or none
im.sliderint(label: string, i: int, min: int, max: int) -> int
im.sliderfloat(label: string, f: float, min: float, max: float) -> float
im.sliderint2(label: string, I2: int2, min: int, max: int) -> int2
im.sliderint3(label: string, I3: int3, min: int, max: int) -> int3
im.sliderint4(label: string, I4: int4, min: int, max: int) -> int4
im.sliderfloat2(label: string, F2: float2, min: float, max: float) -> float2
im.sliderfloat3(label: string, F3: float3, min: float, max: float) -> float3
im.sliderfloat4(label: string, F4: float4, min: float, max: float) -> float4
im.coloredit(label: string, color: floatN) -> any
im.image(tex: resource<texture>, size: float2, flip: bool = false)
im.image_button(label: string, tex: resource<texture>, size: float2, bgcol: float4 = nil, flip: bool = false) -> int
im.image_mouseclick(tex: resource<texture>, size: float2) -> float2, int
im.rect(min: float2, max: float2, color: float4, rounding: float, thickness: float)
im.rect_filled(min: float2, max: float2, color: float4, rounding: float)
im.treenode_start(label: string, flags: int) -> int(use im.treenode instead)
im.treenode_end()
im.tab_bar_start(label: string) -> int(use im.tab_bar instead)
im.tab_bar_end()
im.tab_start(label: string, flags: int) -> int(use im.tab instead)
im.tab_end()
im.menu_bar_start(main: bool) -> int(use im.menu_bar instead)
im.menu_bar_end(main: bool)
im.menu_start(label: string, disabled: bool = false) -> int(use im.menu instead)
im.menu_end()
im.menu_item(label: string, shortcut: string = nil, disabled: bool = false) -> int
im.menu_item_toggle(label: string, selected: bool = false, disabled: bool = false) -> int
im.id_start(label: string)an invisble group around some widgets, useful to ensure these widgets are unique (if they have the same label as widgets in another group that has a different group label). Use im.id instead
im.id_start(label: int)(integer version)
im.id_start(label: any)(reference version)
im.id_end()
im.child_start(title: string, size: float2, flags: int)create a self-contained scrolling/clipping region with a window. use im.child instead
im.child_end()
im.group_start()lock the horizontal starting position, and capture all contained widgets into one item. Use im.group instead
im.group_end()
im.popup_start(label: string, winflags: int, rmbprevitem: bool = false) -> int(use im.popup instead)
im.popup_end()
im.popup_open(label: string)
im.close_current_popup()
im.disabled_start(disabled: bool)(use im.disabled instead)
im.disabled_end()
im.button_repeat_start(repeat: bool)(use im.button_repeat instead)
im.button_repeat_end()
im.drag_drop_source_start(flags: int) -> int(use im.drag_drop_source instead)
im.drag_drop_source_end()
im.set_drag_drop_payload(type: string, data: string)
im.drag_drop_target_start() -> int(use im.drag_drop_target instead)
im.drag_drop_target_end()
im.accept_drag_drop_payload(type: string, flags: int) -> string?
im.width_start(width: float)Sets the width of an item: 0 = default, -1 = use full width without label, any other value is custom width. Use im.width instead
im.width_end()
im.text_table(id: string, num_colums: int, labels: [string])
im.table_start(id: string, num_colums: int, flags: int) -> int(use im.table instead)
im.table_setup_column(label: string, flags: int, init_width_or_weight: float)(use im.table instead)
im.table_headers_row()
im.table_next_row()
im.table_next_column()
im.table_end()
im.edit_anything(value: any, label: string = nil) -> anycreates a UI for any lobster reference value, and returns the edited version
im.graph(label: string, values: [float], ishistogram: int)
im.show_flexbuffer(value: string)
im.show_vars()shows an automatic editing UI for each global variable in your program
im.show_engine_stats()
im.show_debug_metrics_window()

imguidebug

breakpoint(condition: int)stops the program in the debugger if passed true. debugger needs --runtime-stack-trace on, and im.init() to have run.
breakpoint()stops the program in the debugger always. debugger needs --runtime-stack-trace on, and im.init() to have run.