API
This API Reference Manual documents all of classes, enumerations, data types, services, event, callbacks, and properties developers use while creating there game universes.
BrickVerse Globals
Functions
Returns an iterator function, the passed table t and nil, so that the construction will iterate over all key/value pairs of that table when used in a generic for-loop: |
Calls the function func with the given arguments in protected mode. This means that any error inside func is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message. |
Receives any number of arguments, and prints their values to the output. |
Loads Lua code from a string, and returns it as a function. This cannot load the binary version of Lua using loadstring. |
Variant require ( ModuleScript module ) |
Runs the supplied If the ModuleScript the user wants to use has been uploaded to BrickVerse (with the instance’s name being ‘MainModule’), it can be loaded by using the require function on the asset ID of the ModuleScript, though only on the server. |
Returns the type of the object specified, as a string. This function is more accurate than Lua’s native type function, as it does not denote BrickVerse-specific types as userdata. |
Yields the current thread until the specified amount of seconds have elapsed. The delay will have a minimum duration of 29 milliseconds, but this minimum may be higher depending on the target framerate and various throttling conditions. If the seconds parameter is not specified, the minimum duration will be used. This function returns:
|
Behaves identically to Lua’s print function, except the output is styled as a warning, with yellow text and a timestamp. This function accepts any number of arguments, and will attempt to convert them into strings which will then be joined together with spaces between them. |
Schedules a function to be executed after delayTime seconds have passed, without yielding the current thread. This function allows multiple Lua threads to be executed in parallel from the same stack. The delay will have a minimum duration of 29 milliseconds, but this minimum may be higher depending on the target framerate and various throttling conditions. If the delayTime parameter is not specified, the minimum duration will be used. |
Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format. If the metatable of |
Attempts to convert the arg into a number with a specified base to interpret the value in. If it cannot be converted, this function returns nil. The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter ‘A’ (in either upper or lower case) represents 10, ‘B’ represents 11, and so forth, with ‘Z’ representing 35. In base 10 (the default), the number may have a decimal part, as well as an optional exponent part. In other bases, only unsigned integers are accepted. If a string begins with “0x” and a base is not provided, the 0x is trimmed and the base is assumed to be 16, or hexadecimal. |
Throws an error if the provided |
Performs an operation on the Lua garbage collector based on the specified option. BrickVerse's Lua sandbox only allows the “count” option to be used, so none of the other standard options are available. The “count” option returns the total memory in use by Lua (in kilobytes). |
Terminates the last protected function called and outputs message as an error message. If the function containing the error is not called in a protected function (pcall), then the script which called the function will terminate. The error function itself never returns and acts like a script error. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message. |
Variables
string _VERSION |
A global variable (not a function) that holds a string containing the current interpreter version. |
DataModel game |
A reference to the |
DataModel Scene |
LuaSourceContainer script |
A reference to the script object that is executing the code you are writing.
It can be either a This variable is not available when executing code from BrickVerse Studio’s command bar. |
array shared |
table that is shared between all scripts of the same context level. Only shared across same authority level, for example it can't go across client -> server / server -> client. Only server -> server / client -> client. |
array _G |
A table that is shared between all scripts of the same context level. Same as _shared. |
Bool IsCoreScript |
Boolean variable if it's a corescript. Variable can be set, however it has no affect. |
Lua Globals
mathLast updated