🌎_G

assert

assert(expression: any[, text: string, ...]): any

If the result of the first argument is false or nil, an error is thrown with the second argument as the message.

error

error(text: any[, level: number])

Throws a Lua error and breaks out of the current call stack.

getmetatable

getmetatable(object: any): any

Returns the metatable of an object. This function obeys the metatable's __metatable field, and will return that field if the metatable has it set.

ipairs

ipairs(tbl: table): function, table, number

Returns an iterator function for a for loop, to return ordered key-value pairs from a table.

print

print(text: string[, ...])

Prints the text to the console.

print_error(text: string[, ...])

Prints an error to the console and plays a sound.

print_chat(text: string[, ...])

Prints the text to the in-game chat.

print_raw(text: string[, ...])

Prints the text that can be changed in color by prepending it with "\a" followed by the color in the hexadecimal "RRGGBB" format. For example, "\aFF0000Hi" will print "Hi" in red.

print_dev(text: string[, ...])

Prints the text into the upper-left console panel.

tonumber

tonumber(value: any[, base: number]): number

Returns the numeric representation of the value with the given base, or nil if the conversion failed.

tostring

tostring(var: any): string

Returns the string representation of the value.

type

type(var: any): string

Returns the name of the object's type.

unpack

unpack(tbl: table, start_index: number, end_index: number): ...

xpcall

xpcall(func: function, err_callback: function[, ...]): boolean, ...

Attempts to call the first function. If the execution succeeds, this returns true followed by the returns of the function. If execution fails, this returns false and the second function is called with the error message.

to_ticks

to_ticks(time: number): number

Converts time (seconds) to ticks.

to_time

to_time(ticks: number): number

Converts ticks to time (seconds).

new_class

ℹī¸ This class system makes it easier to structure code in complex projects.

new_class(): metatable

Creates the new class.

local ctx = new_class()
    :struct 'struct_one' {
        variable1 = 'test',
        
        some_function = function(self, arg1)
            print(arg1)
            print(string.format('Hello World (%s)', self.variable1))
        end
    }
    
ctx.struct_one:some_function('test')

Last updated