Neverlose
Ask or search…
K
Comment on page
🌎

_G

assert

assert(expression: any[, text: string, ...]): any
Name
Type
Description
expression
any
The expression to assert.
text
text
The error message to throw when assertion fails. This is only type-checked if the assertion fails.
...
any
Any arguments past the error message will be returned by a successful assert.
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])
Name
Type
Description
text
string
The error message to throw.
level
number
The level to throw the error at.
Throws a Lua error and breaks out of the current call stack.

getmetatable

getmetatable(object: any): any
Name
Type
Description
object
any
The value to return the metatable of.
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
Name
Type
Description
tbl
table
The table to iterate over.
Returns an iterator function for a for loop, to return ordered key-value pairs from a table.

print

print(text: string[, ...])
Name
Type
Description
text
string
Text to print into the console.
...
any
Optional arguments to concatenate with text.
Prints the text to the console.
print_error(text: string[, ...])
Name
Type
Description
text
string
Text to print into the console.
...
any
Optional arguments to concatenate with text.
Prints an error to the console and plays a sound.
print_chat(text: string[, ...])
Name
Type
Description
text
string
Text to print into the in-game chat.
...
any
Optional arguments to concatenate with text.
Prints the text to the in-game chat.
print_raw(text: string[, ...])
Name
Type
Description
text
string
Text to print into the console.
...
any
Optional arguments to concatenate with text.
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[, ...])
Name
Type
Description
text
string
Text to print to into the upper-left console panel.
...
any
Optional arguments to concatenate with text.
Prints the text into the upper-left console panel.

tonumber

tonumber(value: any[, base: number]): number
Name
Type
Description
value
any
The value to convert. Can be a number or string.
base
number
Optional. The base used in the string. Can be any integer between 2 and 36, inclusive.
Returns the numeric representation of the value with the given base, or nil if the conversion failed.

tostring

tostring(var: any): string
Name
Type
Description
var
any
The object to be converted to a string.
Returns the string representation of the value.

type

type(var: any): string
Name
Type
Description
var
any
The object to get the type of.
Returns the name of the object's type.

unpack

unpack(tbl: table, start_index: number, end_index: number): ...
Name
Type
Description
tbl
table
The table to generate the vararg from.
start_index
number
Which index to start from. Optional.
end_index
number
Which index to end at. Optional, even if you set start_index.

xpcall

xpcall(func: function, err_callback: function[, ...]): boolean, ...
Name
Type
Description
func
function
The function to call initially.
err_callback
function
The function to be called if execution of the first fails. The error message is passed as a string.
...
any
Arguments to pass to the initial function.
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
Name
Type
Description
time
number
The seconds to convert to ticks.
Converts time (seconds) to ticks.

to_time

to_time(ticks: number): number
Name
Type
Description
ticks
number
The number of ticks to convert to time.
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.
Example1
Example2
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')
You can also create multiple structs and access one from another.
local ctx = new_class()
:struct 'struct_one' {
variable = 1,
some_function = function(self)
print(string.format(
'variable from struct_two: %d',
self.struct_two.variable
))
end
}
:struct 'struct_two' {
variable = 2,
some_function = function(self)
print(string.format(
'variable from struct_one: %d',
self.struct_one.variable
))
end
}
ctx.struct_two:some_function()
ctx.struct_one:some_function()
print(ctx.struct_one.variable)