LuaState class

A lua state.

Binds lua_State.

Note: Many of the docs for methods on this class are abridged versions of the documentation contained in the reference manual. Please read that page for the full documentation.

Constructors

LuaState(Lua lua, Pointer<lua_State> pointer)
Create an instance.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
lua Lua
The LUA bindings to use.
final
pointer Pointer<lua_State>
The pointer to use.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
top int
Returns the index of the top element in the stack.
getter/setter pair
version double
Returns the version number of this core.
no setter

Methods

absIndex(int index) int
Converts the acceptable index idx into an equivalent absolute index (that is, one that does not depend on the stack size).
arith(int op) → void
Performs an arithmetic or bitwise operation over the two values (or one, in the case of negations) at the top of the stack, with the value on the top being the second operand, pops these values, and pushes the result of the operation.
atpanic(lua_CFunction panicf) → lua_CFunction
Registers a new at panic function, and returns the old one.
checkStack(int n) bool
Ensures that the stack has space for at least n extra elements, that is, that you can safely push up to n values into it.
close() → void
Close all active to-be-closed variables in the main thread, release all objects in the given Lua state (calling the corresponding garbage- collection metamethods, if any), and frees all dynamic memory used by this state.
compare(int index1, int index2, int op) bool
Compares two Lua values.
copy(int fromIndex, int toIndex) → void
Copies the element at index fromidx into the valid index toidx, replacing the value at that position.
createTable(int narr, int nrec) → void
Creates a new empty table and pushes it onto the stack.
getField(int index, String k) LuaType
Pushes onto the stack the value t[k], where t is the value at the given index.
getGlobal(String name) LuaType
Pushes onto the stack the value of the global name.
getI(int index, int n) LuaType
Pushes onto the stack the value t[i], where t is the value at the given index.
getIUserValue(int index, int n) LuaType
Pushes onto the stack the n-th user value associated with the full userdata at the given index and returns the type of the pushed value.
getMetaTable(int index) bool
If the value at the given index has a metatable, the function pushes that metatable onto the stack and returns true. Otherwise, the function returns false and pushes nothing on the stack.
getRawI(int index, int n) LuaType
Pushes onto the stack the value t[n], where t is the table at the given index.
getTable(int index) LuaType
Pushes onto the stack the value t[k], where t is the value at the given index and k is the value on the top of the stack.
getType(int index) LuaType
Returns the type of the value in the given valid index, or LuaType.none for a non-valid but acceptable index.
getTypeName(LuaType tp) String
Returns the name of the type encoded by the value tp, which must be one of the values of LuaType.
isCFunction(int index) → void
Returns true if the value at the given index is a C function, and false otherwise.
isInteger(int index) bool
Returns true if the value at the given index is an integer (that is, the value is a number and is represented as an integer), and false otherwise.
isNumber(int index) bool
Returns true if the value at the given index is a number or a string convertible to a number, and false otherwise.
isString(int index) bool
Returns true if the value at the given index is a string or a number (which is always convertible to a string), and false otherwise.
isUserData(int index) bool
Returns true if the value at the given index is a userdata (either full or light), and false otherwise.
moveX(LuaState to, int n) → void
Exchange values between different threads of the same state.
newThread() LuaState
Creates a new thread, pushes it on the stack, and returns a LuaState that represents this new thread.
newUserdataV(int sz, int nuvalue) Pointer<Void>
This function creates and pushes on the stack a new full userdata, with nuvalue associated Lua values, called user values, plus an associated block of raw memory with size sz bytes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pushBoolean(bool b) → void
Pushes a boolean value with value b onto the stack.
pushCClosure(lua_CFunction fn, int n) → void
Pushes a new C closure fn onto the stack.
pushFString(String fmt) Pointer<Int8>
Pushes onto the stack a formatted string fmt and returns a pointer to this string.
pushInteger(int n) → void
Pushes an integer with value n onto the stack.
pushLightUserdata(Pointer<Void> p) → void
Pushes a light userdata p onto the stack.
pushLString(String s) Pointer<Int8>
Pushes the string s onto the stack.
pushNil() → void
Pushes a nil value onto the stack.
pushNumber(double n) → void
Pushes a double with value n onto the stack.
pushString(String s) Pointer<Int8>
Pushes the string s onto the stack.
pushThread() bool
Pushes this thread onto the stack.
pushValue(int index) → void
Pushes a copy of the element at the given index onto the stack.
pushVfString(String fmt, String argp) Pointer<Int8>
See the reference manual.
rawEqual(int index1, int index2) bool
Returns 1 if the two values in indices index1 and index2 are primitively equal.
rawGet(int index) LuaType
Similar to getTable, but does a raw access (i.e., without metamethods).
rawGetP(int index, Pointer<Void> p) LuaType
Pushes onto the stack the value t[k], where t is the table at the given index and k is the pointer p represented as a light userdata.
rawLen(int index) int
Returns the raw "length" of the value at the given index.
rawSet(int index) → void
Similar to setTable, but does a raw assignment (i.e., without metamethods).
rawSetI(int index, int n) → void
Does the equivalent of t[i] = v, where t is the table at the given index and v is the value on the top of the stack.
rawSetP(int index, Pointer<Void> p) → void
Does the equivalent of [tp = v], where t is the table at the given index, p is encoded as a light userdata, and v is the value on the top of the stack.
resetThread() int
Resets a thread, cleaning its call stack and closing all pending to-be- closed variables.
rotate(int index, int n) → void
Rotates the stack elements between the valid index idx and the top of the stack.
setField(int index, String k) → void
Does the equivalent to t[k] = v, where t is the value at the given index and v is the value on the top of the stack.
setGlobal(String name) → void
Pops a value from the stack and sets it as the new value of global name.
setI(int index, int n) → void
Does the equivalent to t[n] = v, where t is the value at the given index and v is the value on the top of the stack.
setIUserValue(int index, int n) → void
Pops a value from the stack and sets it as the new n-th user value associated to the full userdata at the given index.
setMetaTable(int index) int
Pops a table or nil from the stack and sets that value as the new metatable for the value at the given index. (nil means no metatable.)
setTable(int index) → void
Does the equivalent to t[k] = v, where t is the value at the given index, v is the value on the top of the stack, and k is the value just below the top.
toBoolean(int index) bool
Converts the Lua value at the given index to a boolean value (false or true).
toCFunction(int index) → lua_CFunction?
Converts a value at the given index to a C function.
toIntegerX(int index) int
Converts the Lua value at the given index to an integer.
toLString(int index) String
Lua Docs.
toNumberX(int index) double
Converts the Lua value at the given index to a double.
toPointer(int index) Pointer<Void>?
Converts the value at the given index to a generic C pointer. Lua Docs.
toString() String
A string representation of this object.
inherited
toThread(int index) LuaState?
Lua Docs.
toUserdata(int index) Pointer<Void>?
Returns the value at the given index as userdata.

Operators

operator ==(Object other) bool
The equality operator.
inherited