{"modulePath":"github.com/Shopify/go-lua","version":"v0.0.0-20261007132305-3f823f845ff9","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package lua\n\nPackage lua is a port of the Lua VM from [http://lua.org/](http://lua.org/) from C to Go.\n\n## Constants\n\n```go\nconst (\n\tHookCall, MaskCall = iota, 1 \u003c\u003c iota\n\tHookReturn, MaskReturn\n\tHookLine, MaskLine\n\tHookCount, MaskCount\n\tHookTailCall, MaskTailCall\n)\n```\nDebug.Event and SetDebugHook mask argument values.\n\n```go\nconst (\n\t// RegistryIndex is the pseudo-index for the registry table.\n\tRegistryIndex = firstPseudoIndex\n\n\t// RegistryIndexMainThread is the registry index for the main thread of the\n\t// State. (The main thread is the one created together with the State.)\n\tRegistryIndexMainThread = iota\n\n\t// RegistryIndexGlobals is the registry index for the global environment.\n\tRegistryIndexGlobals\n)\n```\nLua provides a registry, a predefined table, that can be used by any Go code to store whatever Lua values it needs to store. The registry table is always located at pseudo-index RegistryIndex, which is a valid index. Any Go library can store data into this table, but it should take care to choose keys that are different from those used by other libraries, to avoid collisions. Typically, you should use as key a string containing your library name, or a light userdata object in your code, or any Lua object created by your code. As with global names, string keys starting with an underscore followed by uppercase letters are reserved for Lua.\n\nThe integer keys in the registry are used by the reference mechanism and by some predefined values. Therefore, integer keys should not be used for other purposes.\n\nWhen you create a new Lua state, its registry comes with some predefined values. These predefined values are indexed with integer keys defined as constants.\n\n```go\nconst (\n\tVersionMajor  = 5\n\tVersionMinor  = 2\n\tVersionNumber = 502\n\tVersionString = \"Lua \" + string('0'+VersionMajor) + \".\" + string('0'+VersionMinor)\n)\n```\n\n```go\nconst MinStack = 20\n```\nMinStack is the minimum Lua stack available to a Go function.\n\n```go\nconst MultipleReturns = -1\n```\nMultipleReturns is the argument for argCount or resultCount in ProtectedCall and Call.\n\n```go\nconst Signature = \"\\033Lua\"\n```\nSignature is the mark for precompiled code ('\\\u003cesc\u003eLua').\n\n## Variables\n\n```go\nvar (\n\tSyntaxError = errors.New(\"syntax error\")\n\tMemoryError = errors.New(\"memory error\")\n\tErrorError  = errors.New(\"error within the error handler\")\n\tFileError   = errors.New(\"file error\")\n)\n```\nErrors introduced by the Lua VM.\n\n## Functions\n\n```go\nfunc ArgumentCheck(l *State, cond bool, index int, extraMessage string)\n```\nArgumentCheck checks whether cond is true. If not, raises an error with a standard message.\n\n```go\nfunc ArgumentError(l *State, argCount int, extraMessage string)\n```\nArgumentError raises an error with a standard message that includes extraMessage as a comment.\n\nThis function never returns. It is an idiom to use it in Go functions as\n\n\tlua.ArgumentError(l, args, \"message\")\n\tpanic(\"unreachable\")\n\n```go\nfunc BaseOpen(l *State) int\n```\nBaseOpen opens the basic library. Usually passed to Require.\n\n```go\nfunc Bit32Open(l *State) int\n```\nBit32Open opens the bit32 library. Usually passed to Require.\n\n```go\nfunc CallMeta(l *State, index int, event string) bool\n```\nCallMeta calls a metamethod.\n\nIf the object at index has a metatable and this metatable has a field event, this function calls this field passing the object as its only argument. In this case this function returns true and pushes onto the stack the value returned by the call. If there is no metatable or no metamethod, this function returns false (without pushing any value on the stack).\n\n```go\nfunc CheckAny(l *State, index int)\n```\nCheckAny checks whether the function has an argument of any type (including nil) at position index.\n\n```go\nfunc CheckInteger(l *State, index int) int\n```\n\n```go\nfunc CheckNumber(l *State, index int) float64\n```\n\n```go\nfunc CheckOption(l *State, index int, def string, list []string) int\n```\n\n```go\nfunc CheckStackWithMessage(l *State, space int, message string)\n```\n\n```go\nfunc CheckString(l *State, index int) string\n```\nCheckString checks whether the function argument at index is a string and returns this string.\n\nThis function uses ToString to get its result, so all conversions and caveats of that function apply here.\n\n```go\nfunc CheckType(l *State, index int, t Type)\n```\nCheckType checks whether the function argument at index has type t. See Type for the encoding of types for t.\n\n```go\nfunc CheckUnsigned(l *State, index int) uint\n```\n\n```go\nfunc CheckUserData(l *State, index int, name string) interface{}\n```\nCheckUserData checks whether the function argument at index is a userdata of the type name (see NewMetaTable) and returns the userdata (see ToUserData).\n\n```go\nfunc DebugHookCount(l *State) int\n```\nDebugHookCount returns the current hook count.\n\n```go\nfunc DebugHookMask(l *State) byte\n```\nDebugHookMask returns the current hook mask.\n\n```go\nfunc DebugOpen(l *State) int\n```\nDebugOpen opens the debug library. Usually passed to Require.\n\n```go\nfunc DoFile(l *State, fileName string) error\n```\nDoFile loads and runs the given file.\n\nThe file may contain either Lua source or a precompiled binary chunk. See LoadString for the trust requirement that binary chunks carry.\n\n```go\nfunc DoString(l *State, s string) error\n```\nDoString loads and runs the given string.\n\nThe string may contain either Lua source or a precompiled binary chunk. See LoadString for the trust requirement that binary chunks carry.\n\n```go\nfunc Errorf(l *State, format string, a ...interface{})\n```\nErrorf raises an error. The error message format is given by format plus any extra arguments, following the same rules as PushFString. It also adds at the beginning of the message the file name and the line number where the error occurred, if this information is available.\n\nThis function never returns. It is an idiom to use it in Go functions as:\n\n\tlua.Errorf(l, args)\n\tpanic(\"unreachable\")\n\n```go\nfunc FileResult(l *State, err error, filename string) int\n```\nFileResult produces the return values for file-related functions in the standard library (io.open, os.rename, file:seek, etc.).\n\n```go\nfunc IOOpen(l *State) int\n```\nIOOpen opens the io library. Usually passed to Require.\n\n```go\nfunc LengthEx(l *State, index int) int\n```\n\n```go\nfunc LoadBuffer(l *State, b, name, mode string) error\n```\nLoadBuffer loads the given string as a chunk named name, without running it. The mode is as described for (\\*State).Load: \"t\" permits only text chunks, \"b\" only binary chunks, and \"\" (or any other value) permits both.\n\n```go\nfunc LoadFile(l *State, fileName, mode string) error\n```\n\n```go\nfunc LoadString(l *State, s string) error\n```\nLoadString loads the given string as a chunk, without running it.\n\nThe chunk may be either Lua source or a precompiled binary chunk. Binary chunks are not verified instruction by instruction, so load them only from a trusted source. For untrusted input, use LoadBuffer with mode \"t\".\n\n```go\nfunc MathOpen(l *State) int\n```\nMathOpen opens the math library. Usually passed to Require.\n\n```go\nfunc MetaField(l *State, index int, event string) bool\n```\nMetaField pushes onto the stack the field event from the metatable of the object at index. If the object does not have a metatable, or if the metatable does not have this field, returns false and pushes nothing.\n\n```go\nfunc MetaTableNamed(l *State, name string)\n```\n\n```go\nfunc NewLibrary(l *State, functions []RegistryFunction)\n```\n\n```go\nfunc NewLibraryTable(l *State, functions []RegistryFunction)\n```\n\n```go\nfunc NewMetaTable(l *State, name string) bool\n```\nNewMetaTable returns false if the registry already has the key name. Otherwise, creates a new table to be used as a metatable for userdata, adds it to the registry with key name, and returns true.\n\nIn both cases it pushes onto the stack the final value associated with name in the registry.\n\n```go\nfunc OSOpen(l *State) int\n```\nOSOpen opens the os library. Usually passed to Require.\n\n```go\nfunc OpenLibraries(l *State, preloaded ...RegistryFunction)\n```\nOpenLibraries opens all standard libraries. Alternatively, the host program can open them individually by using Require to call BaseOpen (for the basic library), PackageOpen (for the package library), CoroutineOpen (for the coroutine library), StringOpen (for the string library), TableOpen (for the table library), MathOpen (for the mathematical library), Bit32Open (for the bit library), IOOpen (for the I/O library), OSOpen (for the Operating System library), and DebugOpen (for the debug library).\n\nThe standard Lua libraries provide useful functions that are implemented directly through the Go API. Some of these functions provide essential services to the language (e.g. Type and MetaTable); others provide access to \"outside\" services (e.g. I/O); and others could be implemented in Lua itself, but are quite useful or have critical performance requirements that deserve an implementation in Go (e.g. table.sort).\n\nAll libraries are implemented through the official Go API. Currently, Lua has the following standard libraries:\n\n\tbasic library\n\tpackage library\n\tstring manipulation\n\ttable manipulation\n\tmathematical functions (sin, log, etc.);\n\tbitwise operations\n\tinput and output\n\toperating system facilities\n\tdebug facilities\n\nExcept for the basic and the package libraries, each library provides all its functions as fields of a global table or as methods of its objects.\n\n```go\nfunc OptInteger(l *State, index, def int) int\n```\n\n```go\nfunc OptNumber(l *State, index int, def float64) float64\n```\n\n```go\nfunc OptString(l *State, index int, def string) string\n```\nOptString returns the string at index if it is a string. If this argument is absent or is nil, returns def. Otherwise, raises an error.\n\n```go\nfunc OptUnsigned(l *State, index int, def uint) uint\n```\n\n```go\nfunc PackageOpen(l *State) int\n```\nPackageOpen opens the package library. Usually passed to Require.\n\n```go\nfunc Require(l *State, name string, f Function, global bool)\n```\nRequire calls function f with string name as an argument and sets the call result in package.loaded\\[name], as if that function had been called through require.\n\nIf global is true, also stores the result into global name.\n\nLeaves a copy of that result on the stack.\n\n```go\nfunc SetDebugHook(l *State, f Hook, mask byte, count int)\n```\nSetDebugHook sets the debugging hook function.\n\nf is the hook function. mask specifies on which events the hook will be called: it is formed by a bitwise or of the constants MaskCall, MaskReturn, MaskLine, and MaskCount. The count argument is only meaningful when the mask includes MaskCount. For each event, the hook is called as explained below:\n\nCall hook is called when the interpreter calls a function. The hook is called just after Lua enters the new function, before the function gets its arguments.\n\nReturn hook is called when the interpreter returns from a function. The hook is called just before Lua leaves the function. There is no standard way to access the values to be returned by the function.\n\nLine hook is called when the interpreter is about to start the execution of a new line of code, or when it jumps back in the code (even to the same line). (This event only happens while Lua is executing a Lua function.)\n\nCount hook is called after the interpreter executes every count instructions. (This event only happens while Lua is executing a Lua function.)\n\nA hook is disabled by setting mask to zero.\n\n```go\nfunc SetFunctions(l *State, functions []RegistryFunction, upValueCount uint8)\n```\n\n```go\nfunc SetMetaTableNamed(l *State, name string)\n```\n\n```go\nfunc SetUpValue(l *State, function, index int) (name string, ok bool)\n```\nSetUpValue sets the value of a closure's upvalue. It assigns the value at the top of the stack to the upvalue and returns its name.  It also pops a value from the stack. function and index are as in UpValue.\n\nReturns an empty string and false if the index is greater than the number of upvalues.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_setupvalue](http://www.lua.org/manual/5.2/manual.html#lua_setupvalue)\n\n```go\nfunc StringOpen(l *State) int\n```\nStringOpen opens the string library. Usually passed to Require.\n\n```go\nfunc SubTable(l *State, index int, name string) bool\n```\n\n```go\nfunc TableOpen(l *State) int\n```\nTableOpen opens the table library. Usually passed to Require.\n\n```go\nfunc TestUserData(l *State, index int, name string) interface{}\n```\n\n```go\nfunc ToStringMeta(l *State, index int) (string, bool)\n```\nToStringMeta converts any Lua value at the given index to a Go string in a reasonable format. The resulting string is pushed onto the stack and also returned by the function.\n\nIf the value has a metatable with a \"\\_\\_tostring\" field, then ToStringMeta calls the corresponding metamethod with the value as argument, and uses the result of the call as its result.\n\n```go\nfunc Traceback(l, l1 *State, message string, level int)\n```\nTraceback creates and pushes a traceback of the stack l1. If message is not nil it is appended at the beginning of the traceback. The level parameter tells at which level to start the traceback.\n\n```go\nfunc TypeNameOf(l *State, index int) string\n```\n\n```go\nfunc UpValue(l *State, function, index int) (name string, ok bool)\n```\nUpValue returns the name of the upvalue at index away from function, where index cannot be greater than the number of upvalues.\n\nReturns an empty string and false if the index is greater than the number of upvalues.\n\n```go\nfunc UpValueId(l *State, f, n int) interface{}\n```\nUpValueId returns a unique identifier for the upvalue numbered n from the closure at index f. Parameters f and n are as in UpValue (but n cannot be greater than the number of upvalues).\n\nThese unique identifiers allow a program to check whether different closures share upvalues. Lua closures that share an upvalue (that is, that access a same external local variable) will return identical ids for those upvalue indices.\n\n```go\nfunc UpValueIndex(i int) int\n```\nUpValueIndex returns the pseudo-index that represents the i-th upvalue of the running function.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_upvalueindex](http://www.lua.org/manual/5.2/manual.html#lua_upvalueindex)\n\n```go\nfunc UpValueJoin(l *State, f1, n1, f2, n2 int)\n```\nUpValueJoin makes the n1-th upvalue of the Lua closure at index f1 refer to the n2-th upvalue of the Lua closure at index f2.\n\n```go\nfunc Version(l *State) *float64\n```\nVersion returns the address of the version number stored in the Lua core.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_version](http://www.lua.org/manual/5.2/manual.html#lua_version)\n\n```go\nfunc Where(l *State, level int)\n```\nWhere pushes onto the stack a string identifying the current position of the control at level in the call stack. Typically this string has the following format:\n\n\tchunkname:currentline:\n\nLevel 0 is the running function, level 1 is the function that called the running function, etc.\n\nThis function is used to build a prefix for error messages.\n\n## Types\n\n```go\ntype ComparisonOperator int\n```\nA ComparisonOperator is an op argument for Compare.\n\n```go\nconst (\n\tOpEq ComparisonOperator = iota // Compares for equality (==).\n\tOpLT                           // Compares for less than (\u003c).\n\tOpLE                           // Compares for less or equal (\u003c=).\n)\n```\nValid ComparisonOperator values for Compare.\n\n```go\ntype Debug struct {\n\tEvent int\n\n\t// Name is a reasonable name for the given function. Because functions in\n\t// Lua are first-class values, they do not have a fixed name. Some functions\n\t// can be the value of multiple global variables, while others can be stored\n\t// only in a table field. The Info function checks how the function was\n\t// called to find a suitable name. If it cannot find a name, then Name is \"\".\n\tName string\n\n\t// NameKind explains the name field. The value of NameKind can be \"global\",\n\t// \"local\", \"method\", \"field\", \"upvalue\", or \"\" (the empty string), according\n\t// to how the function was called. (Lua uses the empty string when no other\n\t// option seems to apply.)\n\tNameKind string\n\n\t// What is the string \"Lua\" if the function is a Lua function, \"Go\" if it is\n\t// a Go function, \"main\" if it is the main part of a chunk.\n\tWhat string\n\n\t// Source is the source of the chunk that created the function. If Source\n\t// starts with a '@', it means that the function was defined in a file where\n\t// the file name follows the '@'. If Source starts with a '=', the remainder\n\t// of its contents describe the source in a user-dependent manner. Otherwise,\n\t// the function was defined in a string where Source is that string.\n\tSource string\n\n\t// ShortSource is a \"printable\" version of source, to be used in error messages.\n\tShortSource string\n\n\t// CurrentLine is the current line where the given function is executing.\n\t// When no line information is available, CurrentLine is set to -1.\n\tCurrentLine int\n\n\t// LineDefined is the line number where the definition of the function starts.\n\tLineDefined int\n\n\t// LastLineDefined is the line number where the definition of the function ends.\n\tLastLineDefined int\n\n\t// UpValueCount is the number of upvalues of the function.\n\tUpValueCount int\n\n\t// ParameterCount is the number of fixed parameters of the function (always 0\n\t// for Go functions).\n\tParameterCount int\n\n\t// IsVarArg is true if the function is a vararg function (always true for Go\n\t// functions).\n\tIsVarArg bool\n\n\t// IsTailCall is true if this function invocation was called by a tail call.\n\t// In this case, the caller of this level is not in the stack.\n\tIsTailCall bool\n\t// contains filtered or unexported fields\n}\n```\nA Debug carries different pieces of information about a function or an activation record. Stack fills only the private part of this structure, for later use. To fill the other fields of a Debug with useful information, call Info.\n\n```go\nfunc Info(l *State, what string, where Frame) (d Debug, ok bool)\n```\nInfo gets information about a specific function or function invocation.\n\nTo get information about a function invocation, the parameter where must be a valid activation record that was filled by a previous call to Stack or given as an argument to a hook (see Hook).\n\nTo get information about a function you push it onto the stack and start the what string with the character '\u003e'. (In that case, Info pops the function from the top of the stack.) For instance, to know in which line a function f was defined, you can write the following code:\n\n\tl.Global(\"f\") // Get global 'f'.\n\td, _ := lua.Info(l, \"\u003eS\", nil)\n\tfmt.Printf(\"%d\\n\", d.LineDefined)\n\nEach character in the string what selects some fields of the Debug struct to be filled or a value to be pushed on the stack:\n\n\t'n': fills in the field Name and NameKind\n\t'S': fills in the fields Source, ShortSource, LineDefined, LastLineDefined, and What\n\t'l': fills in the field CurrentLine\n\t't': fills in the field IsTailCall\n\t'u': fills in the fields UpValueCount, ParameterCount, and IsVarArg\n\t'f': pushes onto the stack the function that is running at the given level\n\t'L': pushes onto the stack a table whose indices are the numbers of the lines that are valid on the function\n\n(A valid line is a line with some associated code, that is, a line where you can put a break point. Non-valid lines include empty lines and comments.)\n\nThis function returns false on error (for instance, an invalid option in what).\n\n```go\ntype Frame *callInfo\n```\nA Frame is a token representing an activation record. It is returned by Stack and passed to Info.\n\n```go\nfunc Stack(l *State, level int) (f Frame, ok bool)\n```\nStack gets information about the interpreter runtime stack.\n\nIt returns a Frame identifying the activation record of the function executing at a given level. Level 0 is the current running function, whereas level n+1 is the function that has called level n (except for tail calls, which do not count on the stack). When there are no errors, Stack returns true; when called with a level greater than the stack depth, it returns false.\n\n```go\ntype Function func(state *State) int\n```\nA Function is a Go function intended to be called from Lua.\n\n```go\nfunc AtPanic(l *State, panicFunction Function) Function\n```\nAtPanic sets a new panic function and returns the old one.\n\n```go\ntype Hook func(state *State, activationRecord Debug)\n```\nA Hook is a callback function that can be registered with SetDebugHook to trace various VM events.\n\n```go\nfunc DebugHook(l *State) Hook\n```\nDebugHook returns the current hook function.\n\n```go\ntype Operator int\n```\nAn Operator is an op argument for Arith.\n\n```go\nconst (\n\tOpAdd        Operator = iota // Performs addition (+).\n\tOpSub                        // Performs subtraction (-).\n\tOpMul                        // Performs multiplication (*).\n\tOpDiv                        // Performs division (/).\n\tOpMod                        // Performs modulo (%).\n\tOpPow                        // Performs exponentiation (^).\n\tOpUnaryMinus                 // Performs mathematical negation (unary -).\n)\n```\nValid Operator values for Arith.\n\n```go\ntype RegistryFunction struct {\n\tName     string\n\tFunction Function\n}\n```\nA RegistryFunction is used for arrays of functions to be registered by SetFunctions. Name is the function name and Function is the function.\n\n```go\ntype RuntimeError string\n```\nA RuntimeError is an error raised internally by the Lua VM or through Error.\n\n```go\nfunc (r RuntimeError) Error() string\n```\n\n```go\ntype State struct {\n\t// contains filtered or unexported fields\n}\n```\nA State is an opaque structure representing per thread Lua state.\n\n```go\nfunc NewState() *State\n```\nNewState creates a new thread running in a new, independent state.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_newstate](http://www.lua.org/manual/5.2/manual.html#lua_newstate)\n\n```go\nfunc NewStateEx() *State\n```\nNewStateEx creates a new Lua state. It calls NewState and then sets a panic function that prints an error message to the standard error output in case of fatal errors.\n\nReturns the new state.\n\n```go\nfunc (l *State) AbsIndex(index int) int\n```\nAbsIndex converts the acceptable index index to an absolute index (that is, one that does not depend on the stack top).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_absindex](http://www.lua.org/manual/5.2/manual.html#lua_absindex)\n\n```go\nfunc (l *State) Arith(op Operator)\n```\nArith performs an arithmetic operation over the two values (or one, in case of negation) at the top of the stack, with the value at the top being the second operand, ops these values and pushes the result of the operation. The function follows the semantics of the corresponding Lua operator (that is, it may call metamethods).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_arith](http://www.lua.org/manual/5.2/manual.html#lua_arith)\n\n```go\nfunc (l *State) Call(argCount, resultCount int)\n```\nCall calls a function. To do so, use the following protocol: first, the function to be called is pushed onto the stack; then, the arguments to the function are pushed in direct order - that is, the first argument is pushed first. Finally, call Call. argCount is the number of arguments that you pushed onto the stack. All arguments and the function value are popped from the stack when the function is called.\n\nThe results are pushed onto the stack when the function returns. The number of results is adjusted to resultCount, unless resultCount is MultipleReturns. In this case, all results from the function are pushed. Lua takes care that the returned values fit into the stack space. The function results are pushed onto the stack in direct order (the first result is pushed first), so that after the call the last result is on the top of the stack.\n\nAny error inside the called function provokes a call to panic().\n\nThe following example shows how the host program can do the equivalent to this Lua code:\n\n\ta = f(\"how\", t.x, 14)\n\nHere it is in Go:\n\n\tl.Global(\"f\")       // Function to be called.\n\tl.PushString(\"how\") // 1st argument.\n\tl.Global(\"t\")       // Table to be indexed.\n\tl.Field(-1, \"x\")    // Push result of t.x (2nd arg).\n\tl.Remove(-2)        // Remove t from the stack.\n\tl.PushInteger(14)   // 3rd argument.\n\tl.Call(3, 1)        // Call f with 3 arguments and 1 result.\n\tl.SetGlobal(\"a\")    // Set global a.\n\nNote that the code above is \"balanced\": at its end, the stack is back to its original configuration. This is considered good programming practice.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_call](http://www.lua.org/manual/5.2/manual.html#lua_call)\n\n```go\nfunc (l *State) CallWithContinuation(argCount, resultCount, context int, continuation Function)\n```\nCallWithContinuation is exactly like Call, but allows the called function to yield.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_callk](http://www.lua.org/manual/5.2/manual.html#lua_callk)\n\n```go\nfunc (l *State) CheckStack(size int) bool\n```\nCheckStack ensures that there are at least size free stack slots in the stack. This call will not panic(), unlike the other Check\\*() functions.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_checkstack](http://www.lua.org/manual/5.2/manual.html#lua_checkstack)\n\n```go\nfunc (l *State) Compare(index1, index2 int, op ComparisonOperator) bool\n```\nCompare compares two values.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_compare](http://www.lua.org/manual/5.2/manual.html#lua_compare)\n\n```go\nfunc (l *State) Concat(n int)\n```\nConcat concatenates the n values at the top of the stack, pops them, and leaves the result at the top. If n is 1, the result is the single value on the stack (that is, the function does nothing); if n is 0, the result is the empty string. Concatenation is performed following the usual semantic of Lua.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_concat](http://www.lua.org/manual/5.2/manual.html#lua_concat)\n\n```go\nfunc (l *State) Context() (int, bool, error)\n```\nContext is called by a continuation function to retrieve the status of the thread and context information. When called in the origin function, it will always return (0, false, nil). When called inside a continuation function, it will return (ctx, shouldYield, err), where ctx is the value that was passed to the callee together with the continuation function.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_getctx](http://www.lua.org/manual/5.2/manual.html#lua_getctx)\n\n```go\nfunc (l *State) Copy(from, to int)\n```\nCopy moves the element at the index from into the valid index to without shifting any element (therefore replacing the value at that position).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_copy](http://www.lua.org/manual/5.2/manual.html#lua_copy)\n\n```go\nfunc (l *State) CreateTable(arrayCount, recordCount int)\n```\nCreateTable creates a new empty table and pushes it onto the stack. arrayCount is a hint for how many elements the table will have as a sequence; recordCount is a hint for how many other elements the table will have.  Lua may use these hints to preallocate memory for the the new table.  This pre-allocation is useful for performance when you know in advance how many elements the table will have.  Otherwise, you can use the function NewTable.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_createtable](http://www.lua.org/manual/5.2/manual.html#lua_createtable)\n\n```go\nfunc (l *State) Dump(w io.Writer) error\n```\nDump dumps a function as a binary chunk. It receives a Lua function on the top of the stack and produces a binary chunk that, if loaded again, results in a function equivalent to the one dumped.\n\n[http://www.lua.org/manual/5.3/manual.html#lua\\_dump](http://www.lua.org/manual/5.3/manual.html#lua_dump)\n\n```go\nfunc (l *State) Error()\n```\nError generates a Lua error.  The error message must be on the stack top. The error can be any of any Lua type. This function will panic().\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_error](http://www.lua.org/manual/5.2/manual.html#lua_error)\n\n```go\nfunc (l *State) Field(index int, name string)\n```\nField pushes onto the stack the value table\\[name], where table is the table on the stack at the given index. This call may trigger a metamethod for the \\_\\_index event.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_getfield](http://www.lua.org/manual/5.2/manual.html#lua_getfield)\n\n```go\nfunc (l *State) Global(name string)\n```\nGlobal pushes onto the stack the value of the global name.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_getglobal](http://www.lua.org/manual/5.2/manual.html#lua_getglobal)\n\n```go\nfunc (l *State) Insert(index int)\n```\nInsert moves the top element into the given valid index, shifting up the elements above this index to open space.  This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_insert](http://www.lua.org/manual/5.2/manual.html#lua_insert)\n\n```go\nfunc (l *State) IsBoolean(index int) bool\n```\nIsBoolean verifies that the value at index is a boolean.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isboolean](http://www.lua.org/manual/5.2/manual.html#lua_isboolean)\n\n```go\nfunc (l *State) IsFunction(index int) bool\n```\nIsFunction verifies that the value at index is a function, either Go or Lua function.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isfunction](http://www.lua.org/manual/5.2/manual.html#lua_isfunction)\n\n```go\nfunc (l *State) IsGoFunction(index int) bool\n```\nIsGoFunction verifies that the value at index is a Go function.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_iscfunction](http://www.lua.org/manual/5.2/manual.html#lua_iscfunction)\n\n```go\nfunc (l *State) IsLightUserData(index int) bool\n```\nIsLightUserData verifies that the value at index is a light userdata.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_islightuserdata](http://www.lua.org/manual/5.2/manual.html#lua_islightuserdata)\n\n```go\nfunc (l *State) IsNil(index int) bool\n```\nIsNil verifies that the value at index is nil.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isnil](http://www.lua.org/manual/5.2/manual.html#lua_isnil)\n\n```go\nfunc (l *State) IsNone(index int) bool\n```\nIsNone verifies that the value at index is not valid.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isnone](http://www.lua.org/manual/5.2/manual.html#lua_isnone)\n\n```go\nfunc (l *State) IsNoneOrNil(index int) bool\n```\nIsNoneOrNil verifies that the value at index is either nil or invalid.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isnonornil](http://www.lua.org/manual/5.2/manual.html#lua_isnonornil).\n\n```go\nfunc (l *State) IsNumber(index int) bool\n```\nIsNumber verifies that the value at index is a number.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isnumber](http://www.lua.org/manual/5.2/manual.html#lua_isnumber)\n\n```go\nfunc (l *State) IsString(index int) bool\n```\nIsString verifies that the value at index is a string, or a number (which is always convertible to a string).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isstring](http://www.lua.org/manual/5.2/manual.html#lua_isstring)\n\n```go\nfunc (l *State) IsTable(index int) bool\n```\nIsTable verifies that the value at index is a table.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_istable](http://www.lua.org/manual/5.2/manual.html#lua_istable)\n\n```go\nfunc (l *State) IsThread(index int) bool\n```\nIsThread verifies that the value at index is a thread.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isthread](http://www.lua.org/manual/5.2/manual.html#lua_isthread)\n\n```go\nfunc (l *State) IsUserData(index int) bool\n```\nIsUserData verifies that the value at index is a userdata.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_isuserdata](http://www.lua.org/manual/5.2/manual.html#lua_isuserdata)\n\n```go\nfunc (l *State) Length(index int)\n```\nLength of the value at index; it is equivalent to the # operator in Lua. The result is pushed on the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_len](http://www.lua.org/manual/5.2/manual.html#lua_len)\n\n```go\nfunc (l *State) Load(r io.Reader, chunkName string, mode string) error\n```\nLoad loads a Lua chunk, without running it. If there are no errors, it pushes the compiled chunk as a Lua function on top of the stack. Otherwise, it pushes an error message.\n\nThe mode controls which kinds of chunk are accepted: \"t\" permits only text chunks, \"b\" only binary chunks, and \"\" (or any other value) permits both. Binary chunks are checked for structural consistency but are not verified instruction by instruction, so a crafted chunk can still make a Lua function misbehave within its own state. Load binary chunks only from a trusted source, and pass \"t\" for input you do not control.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_load](http://www.lua.org/manual/5.2/manual.html#lua_load)\n\n```go\nfunc (l *State) MetaTable(index int) bool\n```\nMetaTable pushes onto the stack the metatable of the value at index.  If the value at index does not have a metatable, the function returns false and nothing is put onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_getmetatable](http://www.lua.org/manual/5.2/manual.html#lua_getmetatable)\n\n```go\nfunc (l *State) NewTable()\n```\nNewTable creates a new empty table and pushes it onto the stack. It is equivalent to l.CreateTable(0, 0).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_newtable](http://www.lua.org/manual/5.2/manual.html#lua_newtable)\n\n```go\nfunc (l *State) Next(index int) bool\n```\nNext pops a key from the stack and pushes a key-value pair from the table at index, while the table has next elements.  If there are no more elements, nothing is pushed on the stack and Next returns false.\n\nA typical traversal looks like this:\n\n\t// Table is on top of the stack (index -1).\n\tl.PushNil() // Add nil entry on stack (need 2 free slots).\n\tfor l.Next(-2) {\n\t\tkey := lua.CheckString(l, -2)\n\t\tval := lua.CheckString(l, -1)\n\t\tl.Pop(1) // Remove val, but need key for the next iter.\n\t}\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_next](http://www.lua.org/manual/5.2/manual.html#lua_next)\n\n```go\nfunc (l *State) Pop(n int)\n```\nPop pops n elements from the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pop](http://www.lua.org/manual/5.2/manual.html#lua_pop)\n\n```go\nfunc (l *State) ProtectedCall(argCount, resultCount, errorFunction int) error\n```\nProtectedCall calls a function in protected mode. Both argCount and resultCount have the same meaning as in Call. If there are no errors during the call, ProtectedCall behaves exactly like Call.\n\nHowever, if there is any error, ProtectedCall catches it, pushes a single value on the stack (the error message), and returns an error. Like Call, ProtectedCall always removes the function and its arguments from the stack.\n\nIf errorFunction is 0, then the error message returned on the stack is exactly the original error message. Otherwise, errorFunction is the stack index of an error handler (in the Lua C, message handler). This cannot be a pseudo-index in the current implementation. In case of runtime errors, this function will be called with the error message and its return value will be the message returned on the stack by ProtectedCall.\n\nTypically, the error handler is used to add more debug information to the error message, such as a stack traceback. Such information cannot be gathered after the return of ProtectedCall, since by then, the stack has unwound.\n\nThe possible errors are the following:\n\n\tRuntimeError  a runtime error\n\tMemoryError   allocating memory, the error handler is not called\n\tErrorError    running the error handler\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pcall](http://www.lua.org/manual/5.2/manual.html#lua_pcall)\n\n```go\nfunc (l *State) ProtectedCallWithContinuation(argCount, resultCount, errorFunction, context int, continuation Function) (err error)\n```\nProtectedCallWithContinuation behaves exactly like ProtectedCall, but allows the called function to yield.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pcallk](http://www.lua.org/manual/5.2/manual.html#lua_pcallk)\n\n```go\nfunc (l *State) PushBoolean(b bool)\n```\nPushBoolean pushes a boolean value with value b onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushboolean](http://www.lua.org/manual/5.2/manual.html#lua_pushboolean)\n\n```go\nfunc (l *State) PushFString(format string, args ...interface{}) string\n```\nPushFString pushes onto the stack a formatted string and returns that string.  It is similar to fmt.Sprintf, but has some differences: the conversion specifiers are quite restricted.  There are no flags, widths, or precisions.  The conversion specifiers can only be %% (inserts a % in the string), %s, %f (a Lua number), %p (a pointer as a hexadecimal numeral), %d and %c (an integer as a byte).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushfstring](http://www.lua.org/manual/5.2/manual.html#lua_pushfstring)\n\n```go\nfunc (l *State) PushGlobalTable()\n```\nPushGlobalTable pushes the global environment onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushglobaltable](http://www.lua.org/manual/5.2/manual.html#lua_pushglobaltable)\n\n```go\nfunc (l *State) PushGoClosure(function Function, upValueCount uint8)\n```\nPushGoClosure pushes a new Go closure onto the stack.\n\nWhen a Go function is created, it is possible to associate some values with it, thus creating a Go closure; these values are then accessible to the function whenever it is called.  To associate values with a Go function, first these values should be pushed onto the stack (when there are multiple values, the first value is pushed first).  Then PushGoClosure is called to create and push the Go function onto the stack, with the argument upValueCount telling how many values should be associated with the function.  Calling PushGoClosure also pops these values from the stack.\n\nWhen upValueCount is 0, this function creates a light Go function, which is just a Go function.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushcclosure](http://www.lua.org/manual/5.2/manual.html#lua_pushcclosure)\n\n```go\nfunc (l *State) PushGoFunction(f Function)\n```\nPushGoFunction pushes a Function implemented in Go onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushcfunction](http://www.lua.org/manual/5.2/manual.html#lua_pushcfunction)\n\n```go\nfunc (l *State) PushInteger(n int)\n```\nPushInteger pushes n onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushinteger](http://www.lua.org/manual/5.2/manual.html#lua_pushinteger)\n\n```go\nfunc (l *State) PushLightUserData(d interface{})\n```\nPushLightUserData pushes a light user data onto the stack. Userdata represents Go values in Lua. A light userdata is an interface{}. Its equality matches the Go rules ([http://golang.org/ref/spec#Comparison\\_operators](http://golang.org/ref/spec#Comparison_operators)).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushlightuserdata](http://www.lua.org/manual/5.2/manual.html#lua_pushlightuserdata)\n\n```go\nfunc (l *State) PushNil()\n```\nPushNil pushes a nil value onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushnil](http://www.lua.org/manual/5.2/manual.html#lua_pushnil)\n\n```go\nfunc (l *State) PushNumber(n float64)\n```\nPushNumber pushes a number onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushnumber](http://www.lua.org/manual/5.2/manual.html#lua_pushnumber)\n\n```go\nfunc (l *State) PushString(s string) string\n```\nPushString pushes a string onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushstring](http://www.lua.org/manual/5.2/manual.html#lua_pushstring)\n\n```go\nfunc (l *State) PushThread() bool\n```\nPushThread pushes the thread l onto the stack.  It returns true if l is the main thread of its state.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushthread](http://www.lua.org/manual/5.2/manual.html#lua_pushthread)\n\n```go\nfunc (l *State) PushUnsigned(n uint)\n```\nPushUnsigned pushes n onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushunsigned](http://www.lua.org/manual/5.2/manual.html#lua_pushunsigned)\n\n```go\nfunc (l *State) PushUserData(d interface{})\n```\nPushUserData is similar to PushLightUserData, but pushes a full userdata onto the stack.\n\n```go\nfunc (l *State) PushValue(index int)\n```\nPushValue pushes a copy of the element at index onto the stack.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_pushvalue](http://www.lua.org/manual/5.2/manual.html#lua_pushvalue)\n\n```go\nfunc (l *State) RawEqual(index1, index2 int) bool\n```\nRawEqual verifies that the values at index1 and index2 are primitively equal (that is, without calling their metamethods).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_rawequal](http://www.lua.org/manual/5.2/manual.html#lua_rawequal)\n\n```go\nfunc (l *State) RawGet(index int)\n```\nRawGet is similar to GetTable, but does a raw access (without metamethods).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_rawget](http://www.lua.org/manual/5.2/manual.html#lua_rawget)\n\n```go\nfunc (l *State) RawGetInt(index, key int)\n```\nRawGetInt pushes onto the stack the value table\\[key] where table is the value at index on the stack. The access is raw, as it doesn't invoke metamethods.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_rawgeti](http://www.lua.org/manual/5.2/manual.html#lua_rawgeti)\n\n```go\nfunc (l *State) RawGetValue(index int, p interface{})\n```\nRawGetValue pushes onto the stack value table\\[p] where table is the value at index on the stack, and p is a light userdata.  The access is raw, as it doesn't invoke metamethods.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_rawgetp](http://www.lua.org/manual/5.2/manual.html#lua_rawgetp)\n\n```go\nfunc (l *State) RawLength(index int) int\n```\nRawLength returns the length of the value at index.  For strings, this is the length.  For tables, this is the result of the # operator with no metamethods.  For userdata, this is the size of the block of memory allocated for the userdata (not implemented yet). For other values, it is 0.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_rawlen](http://www.lua.org/manual/5.2/manual.html#lua_rawlen)\n\n```go\nfunc (l *State) RawSet(index int)\n```\nRawSet is similar to SetTable, but does a raw assignment (without metamethods).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_rawset](http://www.lua.org/manual/5.2/manual.html#lua_rawset)\n\n```go\nfunc (l *State) RawSetInt(index, key int)\n```\nRawSetInt does the equivalent of table\\[n]=v where table is the table at index and v is the value at the top of the stack.\n\nThis function pops the value from the stack.  The assignment is raw; it doesn't invoke metamethods.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_rawseti](http://www.lua.org/manual/5.2/manual.html#lua_rawseti)\n\n```go\nfunc (l *State) Register(name string, f Function)\n```\nRegister sets the Go function f as the new value of global name. If name was already defined, it is overwritten.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_register](http://www.lua.org/manual/5.2/manual.html#lua_register)\n\n```go\nfunc (l *State) Remove(index int)\n```\nRemove the element at the given valid index, shifting down the elements above index to fill the gap. This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_remove](http://www.lua.org/manual/5.2/manual.html#lua_remove)\n\n```go\nfunc (l *State) Replace(index int)\n```\nReplace moves the top element into the given valid index without shifting any element (therefore replacing the value at the given index), and then pops the top element.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_replace](http://www.lua.org/manual/5.2/manual.html#lua_replace)\n\n```go\nfunc (l *State) SetField(index int, key string)\n```\nSetField does the equivalent of table\\[key]=v where table is the value at index and v is the value on top of the stack.\n\nThis function pops the value from the stack. As in Lua, this function may trigger a metamethod for the \\_\\_newindex event.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_setfield](http://www.lua.org/manual/5.2/manual.html#lua_setfield)\n\n```go\nfunc (l *State) SetGlobal(name string)\n```\nSetGlobal pops a value from the stack and sets it as the new value of global name.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_setglobal](http://www.lua.org/manual/5.2/manual.html#lua_setglobal)\n\n```go\nfunc (l *State) SetMetaTable(index int)\n```\nSetMetaTable pops a table from the stack and sets it as the new metatable for the value at index.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_setmetatable](http://www.lua.org/manual/5.2/manual.html#lua_setmetatable)\n\n```go\nfunc (l *State) SetTable(index int)\n```\nSetTable does the equivalent of table\\[key]=v, where table is the value at index, v is the value at the top of the stack and key is the value just below the top.\n\nThe function pops both the key and the value from the stack.  As in Lua, this function may trigger a metamethod for the \\_\\_newindex event.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_settable](http://www.lua.org/manual/5.2/manual.html#lua_settable)\n\n```go\nfunc (l *State) SetTop(index int)\n```\nSetTop accepts any index, or 0, and sets the stack top to index. If the new top is larger than the old one, then the new elements are filled with nil. If index is 0, then all stack elements are removed. Removed elements are cleared, so they are neither visible to Lua code nor kept alive.\n\nIf index is negative, the stack will be decremented by that much. If the decrement is larger than the stack, SetTop will panic().\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_settop](http://www.lua.org/manual/5.2/manual.html#lua_settop)\n\n```go\nfunc (l *State) SetUserValue(index int)\n```\nSetUserValue pops a table or nil from the stack and sets it as the new value associated to the userdata at index.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_setuservalue](http://www.lua.org/manual/5.2/manual.html#lua_setuservalue)\n\n```go\nfunc (l *State) Table(index int)\n```\nTable pushes onto the stack the value table\\[top], where table is the value at index, and top is the value at the top of the stack. This function pops the key from the stack, putting the resulting value in its place.  As in Lua, this function may trigger a metamethod for the \\_\\_index event.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_gettable](http://www.lua.org/manual/5.2/manual.html#lua_gettable)\n\n```go\nfunc (l *State) ToBoolean(index int) bool\n```\nToBoolean converts the Lua value at index to a Go boolean. Like all tests in Lua, the only false values are false booleans and nil. Otherwise, all other Lua values evaluate to true.\n\nTo accept only actual boolean values, use the test IsBoolean.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_toboolean](http://www.lua.org/manual/5.2/manual.html#lua_toboolean)\n\n```go\nfunc (l *State) ToGoFunction(index int) Function\n```\nToGoFunction converts a value at index into a Go function.  That value must be a Go function, otherwise it returns nil.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_tocfunction](http://www.lua.org/manual/5.2/manual.html#lua_tocfunction)\n\n```go\nfunc (l *State) ToInteger(index int) (int, bool)\n```\nToInteger converts the Lua value at index into a signed integer. The Lua value must be a number, or a string convertible to a number.\n\nIf the number is not an integer, it is truncated in some non-specified way.\n\nIf the operation failed, the second return value will be false.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_tointegerx](http://www.lua.org/manual/5.2/manual.html#lua_tointegerx)\n\n```go\nfunc (l *State) ToNumber(index int) (float64, bool)\n```\nToNumber converts the Lua value at index to the Go type for a Lua number (float64). The Lua value must be a number or a string convertible to a number.\n\nIf the operation failed, the second return value will be false.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_tonumberx](http://www.lua.org/manual/5.2/manual.html#lua_tonumberx)\n\n```go\nfunc (l *State) ToString(index int) (s string, ok bool)\n```\nToString  converts the Lua value at index to a Go string.  The Lua value must also be a string or a number; otherwise the function returns false for its second return value.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_tolstring](http://www.lua.org/manual/5.2/manual.html#lua_tolstring)\n\n```go\nfunc (l *State) ToThread(index int) *State\n```\nToThread converts the value at index to a Lua thread (a State). This value must be a thread, otherwise the return value will be nil.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_tothread](http://www.lua.org/manual/5.2/manual.html#lua_tothread)\n\n```go\nfunc (l *State) ToUnsigned(index int) (uint, bool)\n```\nToUnsigned converts the Lua value at index to a Go uint. The Lua value must be a number or a string convertible to a number.\n\nIf the number is not an unsigned integer, it is truncated in some non-specified way.  If the number is outside the range of uint, it is normalized to the remainder of its division by one more than the maximum representable value.\n\nIf the operation failed, the second return value will be false.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_tounsignedx](http://www.lua.org/manual/5.2/manual.html#lua_tounsignedx)\n\n```go\nfunc (l *State) ToUserData(index int) interface{}\n```\nToUserData returns an interface{} of the userdata of the value at index. Otherwise, it returns nil.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_touserdata](http://www.lua.org/manual/5.2/manual.html#lua_touserdata)\n\n```go\nfunc (l *State) ToValue(index int) interface{}\n```\nToValue convertes the value at index into a generic Go interface{}.  The value can be a userdata, a table, a thread, a function, or Go string, bool or float64 types. Otherwise, the function returns nil.\n\nDifferent objects will give different values.  There is no way to convert the value back into its original value.\n\nTypically, this function is used only for debug information.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_tovalue](http://www.lua.org/manual/5.2/manual.html#lua_tovalue)\n\n```go\nfunc (l *State) Top() int\n```\nTop returns the index of the top element in the stack. Because Lua indices start at 1, this result is equal to the number of elements in the stack (hence 0 means an empty stack).\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_gettop](http://www.lua.org/manual/5.2/manual.html#lua_gettop)\n\n```go\nfunc (l *State) TypeOf(index int) Type\n```\nTypeOf returns the type of the value at index, or TypeNone for a non-valid (but acceptable) index.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_type](http://www.lua.org/manual/5.2/manual.html#lua_type)\n\n```go\nfunc (l *State) UserValue(index int)\n```\nUserValue pushes onto the stack the Lua value associated with the userdata at index.  This value must be a table or nil.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_getuservalue](http://www.lua.org/manual/5.2/manual.html#lua_getuservalue)\n\n```go\ntype Type int\n```\nA Type is a symbolic representation of a Lua VM type.\n\n```go\nconst (\n\tTypeNil Type = iota\n\tTypeBoolean\n\tTypeLightUserData\n\tTypeNumber\n\tTypeString\n\tTypeTable\n\tTypeFunction\n\tTypeUserData\n\tTypeThread\n\n\tTypeCount\n\tTypeNone = TypeNil - 1\n)\n```\nValid Type values.\n\n```go\nfunc (t Type) String() string\n```\nString returns the name of Type t.\n\n[http://www.lua.org/manual/5.2/manual.html#lua\\_typename](http://www.lua.org/manual/5.2/manual.html#lua_typename)\n\n","path":"github.com/Shopify/go-lua","name":"lua","synopsis":"Package lua is a port of the Lua VM from http://lua.org/ from C to Go.","isRedistributable":true}
