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

treesheets

ts.goto_root()makes the root of the document the current cell. this is the default at the start of any script, so this function is only needed to return there.
ts.goto_view()makes what the user has zoomed into the current cell
ts.has_selection() -> intwhether there is a selection
ts.goto_selection()makes the current cell the one selected, or the first of a selection
ts.has_parent() -> intwhether the current cell has a parent (is the root cell)
ts.goto_parent()makes the current cell the parent of the current cell, if any
ts.num_children() -> intreturns the total number of children of the current cell (rows * columns). returns 0 if this cell doesn't have a sub-grid at all.
ts.num_columns_rows() -> int2returns the number of columns and rows in the current cell
ts.selection() -> int2, int2returns the (xs,ys) and (x,y) of the current selection, or zeroes if none
ts.goto_child(n: int)makes the current cell the nth child of the current cell. it is a runtime error if the current cell has no sub-grid, or n is not in 0..num_children() - 1.
ts.goto_column_row(col: int, row: int)makes the current cell the child at col / row. it is a runtime error if the current cell has no sub-grid, or col / row is outside of it (see num_columns_rows()).
ts.select()selects the current cell in the document, unfolding, zooming and scrolling to show it once the script is done. it is a runtime error if the current cell is the root, which has no parent grid to select it in.
ts.select_range(position: int2, size: int2)selects the cells denoted by position/size in the grid of the current cell (see selection()), unfolding, zooming and scrolling to show them once the script is done. it is a runtime error if the current cell has no sub-grid, or the cells are not all inside it.
ts.get_text() -> stringgets the text of the current cell.
ts.get_note() -> stringgets the note of the current cell.
ts.set_text(text: string)sets the text of the current cell
ts.set_note(text: string)sets the note of the current cell
ts.create_grid(cols: int, rows: int)creates a grid in the current cell if there is not one yet. cols and rows must be at least 1, and cols * rows at most 65536, or this is a runtime error.
ts.insert_column(c: int)inserts a column before column c in an existing grid
ts.insert_row(r: int)inserts a row before row r in an existing grid
ts.delete(position: int2, size: int2)clears the cells denoted by position/size. also removes columns/rows if they become completely empty, or the entire grid.
ts.set_background_color(color: float4)sets the background color of the current cell
ts.set_text_color(color: float4)sets the text color of the current cell
ts.set_text_filtered(filtered: bool)sets the text filtered of the current cell
ts.is_text_filtered() -> intwhether the text of the current cell is filtered
ts.set_border_color(color: float4)sets the border color of the current grid
ts.get_relative_size() -> intreturns the relative text size of the current cell
ts.set_relative_size(size: int)sets the relative size (0 is normal, -1 is smaller etc.) of the current cell
ts.set_style_bits(stylebits: int)sets one or more styles (bold = 1, italic = 2, fixed = 4, underline = 8, strikethru = 16) on the current cell
ts.get_style_bits() -> intreturns the stylebits of the current cell
ts.set_text_alignment(alignment: int)sets the text alignment of the current cell (automatic = 0, left = 1, center = 2, right = 3). Automatic aligns right-to-left text (such as Arabic or Hebrew) right, and all other text left
ts.get_text_alignment() -> intreturns the text alignment of the current cell (see set_text_alignment)
ts.set_vertical_alignment(alignment: int)sets the vertical alignment of the current cell's text and grid in the height of its row (automatic = 0, top = 1, middle = 2, bottom = 3). Automatic is top, except for cells without a grid in line style, which are centered
ts.get_vertical_alignment() -> intreturns the vertical alignment of the current cell (see set_vertical_alignment)
ts.set_status_message(message: string)sets the status message in TreeSheets
ts.agent_result(result: string)reports a value back to the connected agent for the current eval request, if any
ts.get_filename_from_user(is_save: int) -> stringgets a filename using a file dialog. empty string if cancelled.
ts.get_filename() -> stringgets the current documents file name
ts.load_document(filename: string, password: string = nil) -> intloads a document, and makes it the active one. an encrypted document is decrypted with password if given (a wrong one fails without asking), otherwise a dialog asks for it. returns false if failed.
ts.new_document(cols: int, rows: int)opens a new, unsaved document in a new tab with a root grid of the given size, and makes it the active one. cols and rows must be at least 1, and cols * rows at most 65536, or this is a runtime error.
ts.save_document(saveas: int) -> intsaves the current document to disk, same as the Save (saveas=false) / Save As (saveas=true) menu actions. if the document has no filename yet, always shows a save dialog. returns false if the save failed or the dialog was cancelled.
ts.save_document_as(filename: string) -> intsaves the current document to the given filename, without ever showing a save dialog (unlike save_document(true)). appends .cts if filename has no extension, and makes this the document's filename for subsequent save_document() calls. returns false if failed.
ts.set_password(password: string) -> intsets the password to encrypt the current document with, from its next save on (same as the Set Password menu action). an empty password makes it save unencrypted again. returns false if failed.
ts.set_autoexport(html: int, pdf: bool)sets the exports made alongside the current document whenever it is saved (same as the Autoexport menu items): html 0 = none, 1 = HTML with images, 2 = HTML without images, and pdf = true for a PDF too (only in builds with PDF export). stored in the document, which needs saving afterwards.
ts.get_autoexport() -> int, intreturns the exports made alongside the current document whenever it is saved, as html and pdf (see set_autoexport)
ts.set_window_size(width: int, height: int)resizes the window
ts.get_last_edit() -> intgets the timestamp of the last edit in milliseconds since the Unix/C epoch
ts.get_current_time() -> intgets the current timestamp in milliseconds since the Unix/C epoch
ts.is_tag() -> intwhether the current cell text is a tag
ts.has_image() -> intwhether the current cell has an image
ts.get_column_width() -> intget the column width of the current cell
ts.set_column_width(width: int)set the column width of the current cell
ts.remove_image()remove image in the current cell
ts.set_image(filename: string) -> intset image for the current cell
ts.set_image_display_scale(scale: int)set display scale (in integer percentage)
ts.undo() -> intundoes the last edit, if any. returns whether there was one.
ts.redo() -> intredoes the last undone edit, if any. returns whether there was one.
ts.is_grid() -> intwhether the current cell has a sub-grid
ts.get_cell_type() -> intreturns the evaluation type of the current cell: 0 = data, 1 = operation, 2 = variable assign, 3 = horizontal view, 4 = variable read, 5 = vertical view
ts.is_folded() -> intwhether the current cell's grid is folded (collapsed)
ts.set_folded(folded: bool)folds or unfolds the current cell's grid
ts.get_background_color() -> float4gets the background color of the current cell
ts.get_text_color() -> float4gets the text color of the current cell
ts.get_border_color() -> float4gets the border color of the current grid
ts.get_version() -> stringreturns the TreeSheets version string
ts.get_executable_path() -> stringreturns the path of the running TreeSheets executable
ts.get_data_path(relpath: string) -> stringreturns the path of a data file or folder of TreeSheets, such as "scripts/": next to the executable if it exists there, else in the installed data folder
ts.get_doc_path(relpath: string) -> stringreturns the path of a documentation file or folder of TreeSheets, such as "examples/" or "docs/": next to the executable if it exists there, else in the installed doc folder
ts.find_exact(text: string) -> intsearches the subtree of the current cell (including itself) for a cell whose text exactly equals the given string, and makes it current if found. returns whether a match was found.
ts.copy_current()deep-clones the current cell, including its subtree, into an in-process scripting clipboard, for use with paste_into_current()
ts.paste_into_current() -> intpastes the contents of the scripting clipboard (see copy_current()) into the current cell, the same way a manual paste would. returns false if nothing has been copied yet, or the current cell has no parent (is the root).
ts.get_subtree_text(format: int) -> stringexports the subtree of the current cell to text in one call: 0 = plain indented text, 1 = csv, 2 = xml. much cheaper than manually walking the subtree with goto_child/get_text in a loop.
ts.set_cell_type(type: int)sets the evaluation type of the current cell (see get_cell_type), same as the Program menu items. like there, a cell only becomes an operation (1) if its text is one, otherwise it becomes data. any other type than 0..5 is a runtime error.
ts.evaluate(format: int) -> stringevaluates the current cell the way Program > Run evaluates the whole document (which is what this does on the root cell): fills in the result views in its grid, and returns the result in the given format (see get_subtree_text), or an empty string if there is none. can be undone like any other edit.
ts.grid_count() -> intreturns the number of cells in the grid of the current cell whose text is a number. cells with other text and empty cells are skipped, as is anything inside sub-grids (only the direct children count). this is also what grid_sum, grid_min, grid_max, grid_avg and grid_median aggregate.
ts.grid_sum() -> floatreturns the sum of the numbers in the grid of the current cell (see grid_count), or 0 if there are none
ts.grid_min() -> floatreturns the smallest number in the grid of the current cell (see grid_count), or 0 if there are none
ts.grid_max() -> floatreturns the largest number in the grid of the current cell (see grid_count), or 0 if there are none
ts.grid_avg() -> floatreturns the average of the numbers in the grid of the current cell (see grid_count), or 0 if there are none
ts.grid_median() -> floatreturns the median of the numbers in the grid of the current cell (see grid_count), i.e. the middle one when sorted, or the average of the two middle ones if their count is even. 0 if there are none.

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.
truncate(xs: [any], i: int)removes all elements starting from index i, does nothing if i >= len
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: int1) -> intreturns whether any elements of the numeric struct are true values
any(xs: int2) -> intreturns whether any elements of the numeric struct are true values
any(xs: int3) -> intreturns whether any elements of the numeric struct are true values
any(xs: int4) -> 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: int1) -> intreturns whether all elements of the numeric struct are true values
all(xs: int2) -> intreturns whether all elements of the numeric struct are true values
all(xs: int3) -> intreturns whether all elements of the numeric struct are true values
all(xs: int4) -> 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
split_string(s: string, delimiter: string) -> string, stringreturns two strings, the parts of the input before and after the first delimiter. if not found, returns the input and an empty string
split_string_reverse(s: string, delimiter: string) -> string, stringreturns two strings, the parts of the input before and after the last delimiter. if not found, returns an empty string and the input
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 (or overflow); second return value is true if allcharacters of the string were parsed (and no overflow).
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.
string_with_capacity(capacity: int) -> stringan empty string with room to grow to capacity bytes without moving, for use as a byte buffer (see write_int64_le) or to build up with +=. A string that fits in a small allocation gets at most the room such an allocation has (a few hundred bytes).
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: float2, b: float) -> float2struct elements raised to the power of b
pow(a: float3, b: float) -> float3struct elements raised to the power of b
pow(a: float4, b: float) -> float4struct 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: float1) -> int1the nearest ints >= each component of v
ceiling(v: float2) -> int2the nearest ints >= each component of v
ceiling(v: float3) -> int3the nearest ints >= each component of v
ceiling(v: float4) -> int4the nearest ints >= each component of v
floor(f: float) -> intthe nearest int <= f
floor(v: float1) -> int1the nearest ints <= each component of v
floor(v: float2) -> int2the nearest ints <= each component of v
floor(v: float3) -> int3the nearest ints <= each component of v
floor(v: float4) -> int4the nearest ints <= each component of v
int(f: float) -> intconverts a float to an int by dropping the fraction
int(v: float1) -> int1converts a struct of floats to ints by dropping the fraction
int(v: float2) -> int2converts a struct of floats to ints by dropping the fraction
int(v: float3) -> int3converts a struct of floats to ints by dropping the fraction
int(v: float4) -> int4converts a struct of floats to ints by dropping the fraction
round(f: float) -> intconverts a float to the closest int
round(v: float1) -> int1converts a struct of floats to the closest ints
round(v: float2) -> int2converts a struct of floats to the closest ints
round(v: float3) -> int3converts a struct of floats to the closest ints
round(v: float4) -> int4converts a struct of floats to the closest ints
fraction(f: float) -> floatreturns the fractional part of a float: short for f - floor(f)
fraction(v: float1) -> float1returns the fractional part of a struct of floats
fraction(v: float2) -> float2returns the fractional part of a struct of floats
fraction(v: float3) -> float3returns the fractional part of a struct of floats
fraction(v: float4) -> float4returns the fractional part of a struct of floats
float(i: int) -> floatconverts an int to float
float(v: int1) -> float1converts a struct of ints to floats
float(v: int2) -> float2converts a struct of ints to floats
float(v: int3) -> float3converts a struct of ints to floats
float(v: int4) -> float4converts a struct of ints to floats
sin(angle: float) -> floatthe y coordinate of the normalized vector indicated by angle (in degrees)
sin(angle: float1) -> float1the y coordinates of the normalized vector indicated by the angles (in degrees)
sin(angle: float2) -> float2the y coordinates of the normalized vector indicated by the angles (in degrees)
sin(angle: float3) -> float3the y coordinates of the normalized vector indicated by the angles (in degrees)
sin(angle: float4) -> float4the 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: float1) -> float1the x coordinates of the normalized vector indicated by the angles (in degrees)
cos(angle: float2) -> float2the x coordinates of the normalized vector indicated by the angles (in degrees)
cos(angle: float3) -> float3the x coordinates of the normalized vector indicated by the angles (in degrees)
cos(angle: float4) -> float4the x coordinates of the normalized vector indicated by the angles (in degrees)
tan(angle: float) -> floatthe tangent of an angle (in degrees)
tan(angle: float1) -> float1the tangents of the angles (in degrees)
tan(angle: float2) -> float2the tangents of the angles (in degrees)
tan(angle: float3) -> float3the tangents of the angles (in degrees)
tan(angle: float4) -> float4the 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
normalize(vec: float1) -> float1returns a vector of unit length
normalize(vec: float2) -> float2returns a vector of unit length
normalize(vec: float3) -> float3returns a vector of unit length
normalize(vec: float4) -> float4returns a vector of unit length
dot(a: float1, b: float1) -> floatthe length of vector a when projected onto b (or vice versa)
dot(a: float2, b: float2) -> floatthe length of vector a when projected onto b (or vice versa)
dot(a: float3, b: float3) -> floatthe length of vector a when projected onto b (or vice versa)
dot(a: float4, b: float4) -> floatthe length of vector a when projected onto b (or vice versa)
magnitude(v: float1) -> floatthe geometric length of a vector
magnitude(v: float2) -> floatthe geometric length of a vector
magnitude(v: float3) -> floatthe geometric length of a vector
magnitude(v: float4) -> floatthe geometric length of a vector
magnitude_squared(v: float1) -> floatthe geometric length of a vector squared
magnitude_squared(v: float2) -> floatthe geometric length of a vector squared
magnitude_squared(v: float3) -> floatthe geometric length of a vector squared
magnitude_squared(v: float4) -> floatthe geometric length of a vector squared
magnitude_squared(v: int1) -> intthe geometric length of a vector squared
magnitude_squared(v: int2) -> intthe geometric length of a vector squared
magnitude_squared(v: int3) -> intthe geometric length of a vector squared
magnitude_squared(v: int4) -> intthe geometric length of a vector squared
manhattan(v: int1) -> intthe manhattan distance of a vector
manhattan(v: int2) -> intthe manhattan distance of a vector
manhattan(v: int3) -> intthe manhattan distance of a vector
manhattan(v: int4) -> 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: float1) -> floatthe volume of the area spanned by the vector
volume(v: float2) -> floatthe volume of the area spanned by the vector
volume(v: float3) -> floatthe volume of the area spanned by the vector
volume(v: float4) -> floatthe volume of the area spanned by the vector
volume(v: int1) -> intthe volume of the area spanned by the vector
volume(v: int2) -> intthe volume of the area spanned by the vector
volume(v: int3) -> intthe volume of the area spanned by the vector
volume(v: int4) -> intthe volume of the area spanned by the vector
rnd(max: int) -> inta random value [0..max).
rnd(max: int1) -> int1a random struct within the range of an input struct.
rnd(max: int2) -> int2a random struct within the range of an input struct.
rnd(max: int3) -> int3a random struct within the range of an input struct.
rnd(max: int4) -> int4a random struct within the range of an input struct.
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
rnd_select(index: int) -> intselect a different random number generator to be active. default is 0, max is 1000000. returns previous value.
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: int1, min: int1, max: int1) -> int1forces an integer struct to be in the range between min and max (inclusive)
clamp(x: int2, min: int2, max: int2) -> int2forces an integer struct to be in the range between min and max (inclusive)
clamp(x: int3, min: int3, max: int3) -> int3forces an integer struct to be in the range between min and max (inclusive)
clamp(x: int4, min: int4, max: int4) -> int4forces an integer struct to be in the range between min and max (inclusive)
clamp(x: float1, min: float1, max: float1) -> float1forces a float struct to be in the range between min and max (inclusive)
clamp(x: float2, min: float2, max: float2) -> float2forces a float struct to be in the range between min and max (inclusive)
clamp(x: float3, min: float3, max: float3) -> float3forces a float struct to be in the range between min and max (inclusive)
clamp(x: float4, min: float4, max: float4) -> float4forces a float struct 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 3d 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: int1) -> int1absolute value of an int vector
abs(x: int2) -> int2absolute value of an int vector
abs(x: int3) -> int3absolute value of an int vector
abs(x: int4) -> int4absolute value of an int vector
abs(x: float1) -> float1absolute value of a float vector
abs(x: float2) -> float2absolute value of a float vector
abs(x: float3) -> float3absolute value of a float vector
abs(x: float4) -> float4absolute 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: int1) -> int1signs of an int vector
sign(x: int2) -> int2signs of an int vector
sign(x: int3) -> int3signs of an int vector
sign(x: int4) -> int4signs of an int vector
sign(x: float1) -> int1signs of a float vector
sign(x: float2) -> int2signs of a float vector
sign(x: float3) -> int3signs of a float vector
sign(x: float4) -> int4signs of a float vector
min(x: int, y: int) -> intsmallest of 2 integers.
min(x: float, y: float) -> floatsmallest of 2 floats.
min(x: int1, y: int1) -> int1smallest components of 2 int vectors
min(x: int2, y: int2) -> int2smallest components of 2 int vectors
min(x: int3, y: int3) -> int3smallest components of 2 int vectors
min(x: int4, y: int4) -> int4smallest components of 2 int vectors
min(x: float1, y: float1) -> float1smallest components of 2 float vectors
min(x: float2, y: float2) -> float2smallest components of 2 float vectors
min(x: float3, y: float3) -> float3smallest components of 2 float vectors
min(x: float4, y: float4) -> float4smallest components of 2 float vectors
min(v: int1) -> intsmallest component of a int vector.
min(v: int2) -> intsmallest component of a int vector.
min(v: int3) -> intsmallest component of a int vector.
min(v: int4) -> intsmallest component of a int vector.
min(v: float1) -> floatsmallest component of a float vector.
min(v: float2) -> floatsmallest component of a float vector.
min(v: float3) -> floatsmallest component of a float vector.
min(v: float4) -> floatsmallest component of a float vector.
min(v: [int]) -> intsmallest component of a int vector, or INT64_MAX if length 0.
min(v: [float]) -> floatsmallest component of a float vector, or DBL_MAX if length 0.
max(x: int, y: int) -> intlargest of 2 integers.
max(x: float, y: float) -> floatlargest of 2 floats.
max(x: int1, y: int1) -> int1largest components of 2 int vectors
max(x: int2, y: int2) -> int2largest components of 2 int vectors
max(x: int3, y: int3) -> int3largest components of 2 int vectors
max(x: int4, y: int4) -> int4largest components of 2 int vectors
max(x: float1, y: float1) -> float1largest components of 2 float vectors
max(x: float2, y: float2) -> float2largest components of 2 float vectors
max(x: float3, y: float3) -> float3largest components of 2 float vectors
max(x: float4, y: float4) -> float4largest components of 2 float vectors
max(v: int1) -> intlargest component of a int vector.
max(v: int2) -> intlargest component of a int vector.
max(v: int3) -> intlargest component of a int vector.
max(v: int4) -> intlargest component of a int vector.
max(v: float1) -> floatlargest component of a float vector.
max(v: float2) -> floatlargest component of a float vector.
max(v: float3) -> floatlargest component of a float vector.
max(v: float4) -> floatlargest component of a float vector.
max(v: [int]) -> intlargest component of a int vector, or INT64_MIN if length 0.
max(v: [float]) -> floatlargest component of a float vector, or -DBL_MAX 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: float2, b: float2, f: float) -> float2linearly interpolates between a and b vectors with factor f [0..1]
lerp(a: float3, b: float3, f: float) -> float3linearly interpolates between a and b vectors with factor f [0..1]
lerp(a: float4, b: float4, f: float) -> float4linearly 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: float2, a: float2, b: float2, c: float2, f: float, tension: float) -> float2computes 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)
cardinal_spline(z: float3, a: float3, b: float3, c: float3, f: float, tension: float) -> float3computes 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: int1) -> inthashes a numeric struct into a positive int
hash(v: int2) -> inthashes a numeric struct into a positive int
hash(v: int3) -> inthashes a numeric struct into a positive int
hash(v: int4) -> inthashes a numeric struct into a positive int
hash(v: float1) -> inthashes a numeric struct into a positive int
hash(v: float2) -> inthashes a numeric struct into a positive int
hash(v: float3) -> inthashes a numeric struct into a positive int
hash(v: float4) -> inthashes a numeric struct 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
type_enum_value_name(enum_type_id: typeid(any), idx: int) -> stringstring representing the name of an enum value, belonging to the enum (use typeof)
type_enum_value_valid(enum_type_id: typeid(any), idx: int) -> intwhether an integer is a value of the given enum (use typeof), i.e. whether type_enum_value_name would give it a name, but without allocating a string. Cheap enough to range check a value that may come from elsewhere (such as a file written by a newer version of the program) before switching on it. For an enum_flags, any combination of declared bits is a value, so this is true for more values than a switch on it has cases
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.
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.
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(object: any)put this object in the thread queue
thread_read(type: typeid(any)) -> any?get an object from the thread queue. pass the typeof object. blocks if no such objects available. returns object, or nil if this was the result of thread_wake() or stop_worker_threads() was called
thread_check(type: typeid(any)) -> any?tests if an object is available on the thread queue. pass the typeof object. returns object, or nil if none available, or if stop_worker_threads() was called
thread_wake(type: typeid(any))wakes up one thread that are currently blocked on a thread_read for this type. this will cause them to return nil since no object is sent. it is similar to thread_write(nil)
crash_test_cpp_nullptr_exception()only for testing crash dump functionality, don't use! :)
profiler_dump_stats(num: int, histogram: bool) -> stringreturns a string with CSV data for the num top items
profiler_paused(paused: bool)
profiler_reset()

compiler

compile_run_code(code: string, args: [string], max_errors: int = 1) -> 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. max_errors is how many errors are collected (in the error string, one per line) before giving up, default 1.
compile_run_file(filename: string, args: [string]) -> string, string?same as compile_run_code(), only now you pass a filename.
compile_run_c_code(code: string, input: string) -> string?, string?compiles and runs C source code using the built-in C compiler (available in JIT mode only). the code must contain a main() function, which will be called. input must be a string, whose (mutable) contents are available to the C code thru input_buf() and input_len() (in bytes). additionally available: output_buf(ptr, len) to return a buffer allocated thru malloc/realloc as a string (ownership is transferred, do not free), and further malloc/realloc/free/memcpy/memmove/memset/strlen. all these are pre-declared. returns the output as a string (or nil if output_buf() was never called), plus an error string as second return value (nil if none). note the C code can also modify the input buffer in-place as a way to return data.

file

format_time(format: string, time: int, localtime: bool) -> stringconvert a time in seconds since 00:00:00 UTC, Thursday, 1 January 1970 into a string, using the same format string syntax as POSIX strftime. If localtime is true, then the time will be displayed using the local timezone, otherwise it will use UTC. Returns an empty string on error.
scan_folder(folder: string, rel: bool = false) -> [string]?, [int]?, [int]?returns three 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), and the third as the number of seconds since 00:00:00 UTC, Thursday, 1 January 1970, not including leap seconds. 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, offset: int = 0, len: int = 0) -> 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. Offset and len can specify a slice of the input, but if not specified default to all.
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 it grown to that size (with optionally extra bytes added), with any new characters set to char: grown in place when the string has the room (see string_with_capacity), else as a new string of exactly that size. You can specify a negative size to mean relative to the end, i.e. new characters will be added at the start. Together with the write_ functions this lets a string be used as a byte buffer: those write into the string in place (visible thru every reference to it), except that a string constant is copied first, so a literal never changes.
write_int64_le(string: string, i: int, val: int) -> string, intwrites a value as little endian to a string at location i, in place, so the write is visible thru every reference to the string. A write past the end grows the string to end right after the value (bytes skipped over are 0): in place as well when the string has the room (see string_with_capacity), else as a new string with room to grow as much again, which is what a string that had to grow that way gets. Returns the string, which is the new one if it had to move or was a string constant (see ensure_size), 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), and grows the string to twice what it needs, with 0 bytes at the front, so what it wrote keeps its place from the end
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]

noise

simplex(pos: float2, octaves: int, scale: float, persistence: float) -> floatreturns a simplex noise value [-1..1] given a 2D/3D location, the number of octaves (try 6), a scale (try 0.01), and persistence from one octave to the next (try 0.5). This function is the same as calling fast_noise with simplex/fbm flags.
simplex(pos: float3, octaves: int, scale: float, persistence: float) -> floatreturns a simplex noise value [-1..1] given a 2D/3D location, the number of octaves (try 6), a scale (try 0.01), and persistence from one octave to the next (try 0.5). This function is the same as calling fast_noise with simplex/fbm flags.
simplex_raw(pos: float2) -> floatreturns a simplex noise value [-1..1] given a 2D/3D location
simplex_raw(pos: float3) -> floatreturns a simplex noise value [-1..1] given a 2D/3D location
fast_noise(pos: float2, octaves: int, scale: float, persistence: float, noise_type: int, fractal_type: int) -> floatreturns a noise value [-1..1] given a 2D/3Dlocation, the number of octaves (try 6), a scale (try 0.01), and persistence from one octave to the next (try 0.5). see noise.lobster for constants for the type params.
fast_noise(pos: float3, octaves: int, scale: float, persistence: float, noise_type: int, fractal_type: int) -> floatreturns a noise value [-1..1] given a 2D/3Dlocation, the number of octaves (try 6), a scale (try 0.01), and persistence from one octave to the next (try 0.5). see noise.lobster for constants for the type params.