githubEdit

code-simpleLua globals

The following is a list of functions and variables that are native to Lua. These functions can be used in a standard installation of Lua 5.1.4, though there are some differences in how some work.

assert

assert(value: boolean, error_message: string) -> nil

Throws an error if the provided value is false or nil, stopping execution and displaying the provided error message.

error

error(message: string, level: number) -> nil

Immediately halts execution and throws an error with the given message and optional stack level.

gcinfo

gcinfo() -> number

Returns the current memory usage in kilobytes, providing insight into Lua's garbage collection.

getmetatable

getmetatable(t: table) -> table | nil

Retrieves the metatable of the given table, or nil if no metatable exists.

ipairs

Returns an iterator function for sequentially iterating over an array-like table in order.

newproxy

Creates a blank userdata object, optionally with a metatable for custom behavior.

next

Returns the next key-value pair in a table, allowing iteration when used in a loop.

pairs

Returns an iterator function for traversing all key-value pairs in a table, including non-sequential keys.

pcall

Calls a function safely, returning true and the result if successful, or false and an error message if an error occurs.

print ⚠️

Outputs the provided values to the console for debugging or display purposes.

circle-exclamation

rawequal

Compares two values for equality, ignoring metamethods such as __eq.

rawget

Directly retrieves a value from a table, bypassing any __index metamethods.

rawlen

Returns the length of a table or string without invoking metamethods.

rawset

Directly assigns a value to a table, bypassing any __newindex metamethods.

require

Loads and runs a module script, returning its result if it has already been executed.

select

Returns all arguments after the specified index, or the total argument count if the index is "#".

setmetatable

Assigns a new metatable to the given table, enabling custom behaviors like operator overloading.

tonumber

Converts a value to a number, optionally using a specified base, or returns nil if conversion fails.

tostring

Converts a value into a string representation, typically used for debugging or display.

type

Returns a string representing the type of the given value, such as number, string, or table.

unpack

Returns multiple values from a table, from index i to j, effectively "unpacking" them.

xpcall

Similar to pcall, but allows for a custom error handler function to process errors before they are returned.

Last updated