BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›PUB

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
  • BRL.BMPLoader
  • Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • BRL.FileSystem
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • IO

    • Introduction
    • MaxIO
  • BRL.JPGLoader
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
    • TIntMap
    • TIntKey
    • TPtrMap
    • TPtrKey
    • TStringMap
  • BRL.Math
  • Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PNGLoader
  • BRL.PolledInput
  • Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI
  • BRL.RamStream
  • Random

    • Introduction
    • TRandom

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • BRL.TGALoader
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I
    • SVec4D
    • SVec4F
    • SVec4I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    CSV

    • Introduction
    • TCsvParser
    • TCsvHeader
    • TCsvRow
    • TCsvOptions
    • SCsvColumn

    Format

    • Introduction
    • TFormatter

    Ini

    • Introduction
    • TIni
    • TIniProperty
    • TIniSection

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    TOML

    • Introduction
    • ETomlNodeType
    • TToml
    • ITomlNode
    • STomlDate
    • STomlDateTime
    • STomlTime
    • TTomlArray
    • TTomlInteger
    • TTomlString
    • TTomlTable
    • TTomlBoolean

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

PUB

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • Pub.xmmintrin
  • Pub.ZLib

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister
    • TNoSuchAlgorithmException

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLDisplayMode
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType
Edit

Pub.Lua

"Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight scripting language for any program that needs one." (from "Lua 5.1 Reference Manual" by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes)

This module provides a BlitzMax interface to the Lua main and auxiliary APIs. It is almost complete, the only functions missing are those with variable argument lists (which are not supported by BlitzMax).

The Pub.Lua package contains the full Lua 5.1.4 distribution. The Lua source code is completely integrated into the module, additional DLLs (or shared libraries, resp.) are not required.

Introduction

The following description is not meant as a tutorial, but may still help you to start Lua programming within BlitzMax. More API-related information can be found in the Lua Reference manual

Setting up a Lua VM

Running Lua scripts always require the instantiation of at least one Lua VM:

Local LuaState:Byte Ptr = luaL_newstate()

The result of this instantiation is a pointer to a structure which contains the full state of the new VM and has to be passed as the first argument to almost any other Lua API function.

It is now time to "open" the intrinsic Lua libraries (note: these libraries are part of Pub.Lua now, external DLLs or shared libraries are not necessary):

luaL_openlibs(LuaState)

Always initialize the Lua VM by opening its libraries unless you really know what you are doing!

Usually, creating a single Lua state is sufficient, even further (Lua) threads share the basic Lua state (and its associated environment).

Shutting down a Lua VM

At the end, it's always a good idea to shut down the Lua VM

lua_close(LuaState)

The Lua interpreter has now been terminated and its state variable is no longer valid.

Accessing Lua Globals

The code

lua_pushstring(LuaState, "BMXString")
lua_setglobal (LuaState, "luaglobal")

defines a global Lua variable (called luaglobal) which contains a string (namely "BMXString").

Registering BlitzMax Functions

In order to access BlitzMax features from within a Lua script, it is necessary to implement suitable BlitzMax functions and register them in the Lua VM.

Such BlitzMax functions typically look as follows:

Function BMXName:int (LuaState:Byte Ptr)
    ...    ' handling of parameters passed from Lua (if required)
    ...    ' actual function body
    ...    ' passing results back to Lua (if required)
    return 0 ' number of values returned to Lua
End Function

Such a function is then registered using

lua_register(LuaState, "luaname", BMXName)

This command registers a BlitzMax function (called BMXName) with the (global) name luaname under Lua. Both names may be equal, but they do not have to.

Running Lua Scripts From Within BlitzMax

The code

Local Result:int = luaL_loadString(LuaState,LuaScript)
If Result <> 0 Then<br/>   ' ERROR!!!
    lua_close(LuaState) ' just to be complete
    End
End If

loads and compiles a (BlitzMax) string containing a LuaScript. The result (of compilation) is left on the (Lua) stack.

lua_getfield(LuaState, LUA_GLOBALSINDEX, "debug") ' get global "debug"
lua_getfield(LuaState, -1, "traceback")           ' get "debug.traceback"
lua_remove (LuaState, -2)                         ' remove "debug" table from stack

Result = lua_pcall(LuaState,1,-1,-1)  ' use "debug.traceback" as err.hdlr

If Result <> 0 Then
    ' ERROR
    lua_close(LuaState) ' just to be complete
    End
End if

actually evaluates the previously loaded script. The initially mentioned Lua commands just prepare for proper error messages should the Lua script fail.

Functions

Function lua_atpanic:Byte Ptr (lua_state:Byte Ptr, panicf:Int(ls:Byte Ptr))

Sets a new panic function and returns the old one.

See Lua Reference Manual


Function lua_call (lua_state:Byte Ptr, nargs:Int, nresults:Int)

Calls a function.

See Lua Reference Manual


Function lua_checkstack:Int (lua_state:Byte Ptr, extra:Int)

Ensures that there are at least extra free stack slots in the stack.

See Lua Reference Manual


Function lua_close (lua_state:Byte Ptr)

Destroys all objects in the given Lua state and frees all dynamic memory used by this state.

See Lua Reference Manual


Function lua_concat (lua_state:Byte Ptr, n:Int)

Concatenates the n values at the top of the stack, pops them, and leaves the result at the top.

See Lua Reference Manual


Function lua_cpcall:Int (lua_state:Byte Ptr, func:Int(ls:Byte Ptr), ud:Byte Ptr)

Calls the function func in protected mode.

See Lua Reference Manual


Function lua_createtable (lua_state:Byte Ptr, narr:Int, nrec:Int)

Creates a new empty table and pushes it onto the stack.

See Lua Reference Manual


Function lua_equal:Int (lua_state:Byte Ptr, index1:Int, index2:Int)

Returns 1 if the two values in acceptable indices index1 and index2 are equal.

See Lua Reference Manual


Function lua_error:Int (lua_state:Byte Ptr)

Generates a Lua error.

See Lua Reference Manual


Function lua_gc:Int (lua_state:Byte Ptr, what:Int, data:Int)

Controls the garbage collector.

See Lua Reference Manual


Function lua_getallocf:Byte Ptr (lua_state:Byte Ptr, ud:Byte Ptr Ptr)

Returns the memory-allocation function of a given state.

See Lua Reference Manual


Function lua_getfenv (lua_state:Byte Ptr, index:Int)

Pushes onto the stack the environment table of the value at the given index.

See Lua Reference Manual


Function lua_getfield (lua_state:Byte Ptr, index:Int, k$z)

Pushes onto the stack the value t[k], where t is the value at the given valid index.

See Lua Reference Manual


Function lua_gethook:Byte Ptr (lua_state:Byte Ptr)

Returns the current hook function.

See Lua Reference Manual


Function lua_gethookcount:Int (lua_state:Byte Ptr)

Returns the current hook count.

See Lua Reference Manual


Function lua_gethookmask:Int (lua_state:Byte Ptr)

Returns the current hook mask.

See Lua Reference Manual


Function lua_getinfo:Int (lua_state:Byte Ptr, what$z, ar:lua_Debug Ptr)

Returns information about a specific function or function invocation.

See Lua Reference Manual


Function lua_getlocal$z (lua_state:Byte Ptr, ar:lua_Debug Ptr, n:Int)

Gets information about a local variable of a given activation record.

See Lua Reference Manual


Function lua_getmetatable:Int (lua_state:Byte Ptr, index:Int)

Pushes onto the stack the metatable of the value at the given acceptable index.

See Lua Reference Manual


Function lua_getstack:Int (lua_state:Byte Ptr, level:Int, ar:lua_Debug Ptr)

Get information about the interpreter runtime stack.

See Lua Reference Manual


Function lua_gettable (lua_state:Byte Ptr, index:Int)

Pushes onto the stack the value t[k], where t is the value at the given valid index and k is the value at the top of the stack.

See Lua Reference Manual


Function lua_gettop:Int (lua_state:Byte Ptr)

Returns the index of the top element in the stack.

See Lua Reference Manual


Function lua_getupvalue$z (lua_state:Byte Ptr, funcindex:Int, n:Int)

Gets information about a closure's upvalue.

See Lua Reference Manual


Function lua_insert (lua_state:Byte Ptr, index:Int)

Moves the top element into the given valid index, shifting up the elements above this index to open space.

See Lua Reference Manual


Function lua_iscfunction:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a C function, and 0 otherwise.

See Lua Reference Manual


Function lua_isnumber:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a number or a string convertible to a number, and 0 otherwise.

See Lua Reference Manual


Function lua_isstring:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a string or a number (which is always convertible to a string), and 0 otherwise.

See Lua Reference Manual


Function lua_isuserdata:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a userdata (either full or light), and 0 otherwise.

See Lua Reference Manual


Function lua_lessthan:Int (lua_state:Byte Ptr, index1:Int, index2:Int)

Returns 1 if the value at acceptable index index1 is smaller than the value at acceptable index index2.

See Lua Reference Manual


Function lua_newthread:Byte Ptr (lua_state:Byte Ptr)

Creates a new thread, pushes it on the stack, and returns a pointer to a lua_State that represents this new thread.

See Lua Reference Manual


Function lua_next:Int (lua_state:Byte Ptr, index:Int)

Pops a key from the stack, and pushes a key-value pair from the table at the given index.

See Lua Reference Manual


Function lua_pcall:Int (lua_state:Byte Ptr, nargs:Int, nresults:Int, errfunc:Int)

Calls a function in protected mode.

See Lua Reference Manual


Function lua_pushboolean (lua_state:Byte Ptr, b:Int)

Pushes a boolean value with value b onto the stack.

See Lua Reference Manual


Function lua_pushcclosure (lua_state:Byte Ptr, fn:Int(ls:Byte Ptr), n:Int)

Pushes a new C closure onto the stack.

See Lua Reference Manual


Function lua_pushlightuserdata (lua_state:Byte Ptr, p:Byte Ptr)

Pushes a light userdata onto the stack.

See Lua Reference Manual


Function lua_pushnil (lua_state:Byte Ptr)

Pushes a nil value onto the stack.

See Lua Reference Manual


Function lua_pushnumber (lua_state:Byte Ptr, n:Double)

Pushes a number with value n onto the stack.

See Lua Reference Manual


Function lua_pushstring (lua_state:Byte Ptr, s$z)

Pushes the String pointed to by s onto the stack.

See Lua Reference Manual


Function lua_pushthread:Int (lua_state:Byte Ptr)

Pushes the thread onto the stack.

See Lua Reference Manual


Function lua_pushvalue (lua_state:Byte Ptr, index:Int)

Pushes a copy of the element at the given valid index onto the stack.

See Lua Reference Manual


Function lua_rawequal:Int (lua_state:Byte Ptr, index1:Int, index2:Int)

Returns 1 if the two values in acceptable indices index1 and index2 are primitively equal.

See Lua Reference Manual


Function lua_rawget (lua_state:Byte Ptr, index:Int)

Similar to lua_gettable, but does a raw access

See Lua Reference Manual


Function lua_rawgeti (lua_state:Byte Ptr, index:Int, n:Int)

Pushes onto the stack the value t[n], where t is the value at the given valid index.

See Lua Reference Manual


Function lua_rawset (lua_state:Byte Ptr, index:Int)

Similar to lua_settable, but does a raw assignment.

See Lua Reference Manual


Function lua_rawseti (lua_state:Byte Ptr, index:Int, n:Int)

Does the equivalent of t[n] = v, where t is the value at the given valid index and v is the value at the top of the stack.

See Lua Reference Manual


Function lua_remove (lua_state:Byte Ptr, index:Int)

Removes the element at the given valid index, shifting down the elements above this index to fill the gap.

See Lua Reference Manual


Function lua_replace (lua_state:Byte Ptr, index:Int)

Moves the top element into the given position (and pops it), without shifting any element.

See Lua Reference Manual


Function lua_resume:Int (lua_state:Byte Ptr, narg:Int)

Starts and resumes a coroutine in a given thread.

See Lua Reference Manual


Function lua_setfenv:Int (lua_state:Byte Ptr, index:Int)

Pops a table from the stack and sets it as the new environment for the value at the given index.

See Lua Reference Manual


Function lua_setfield (lua_state:Byte Ptr, index:Int, k$z)

Does the equivalent to t[k] = v, where t is the value at the given valid index and v is the value at the top of the stack.

See Lua Reference Manual


Function lua_sethook:Int (lua_state:Byte Ptr, f(ls:Byte Ptr,ar:lua_Debug Ptr), mask:Int, count:Int)

Sets the debugging hook function.

See Lua Reference Manual


Function lua_setlocal$z (lua_state:Byte Ptr, ar:lua_Debug Ptr, n:Int)

Sets the value of a local variable of a given activation record.

See Lua Reference Manual


Function lua_setmetatable:Int (lua_state:Byte Ptr, index:Int)

Pops a table from the stack and sets it as the new metatable for the value at the given acceptable index.

See Lua Reference Manual


Function lua_settable (lua_state:Byte Ptr, index:Int)

Does the equivalent to t[k] = v, where t is the value at the given valid index, v is the value at the top of the stack, and k is the value just below the top.

See Lua Reference Manual


Function lua_settop (lua_state:Byte Ptr, index:Int)

Accepts any acceptable index, or 0, and sets the stack top to this index.

See Lua Reference Manual


Function lua_setupvalue$z (lua_state:Byte Ptr, funcindex:Int, n:Int)

Sets the value of a closure's upvalue.

See Lua Reference Manual


Function lua_status:Int (lua_state:Byte Ptr)

Returns the status of the thread lua_state.

See Lua Reference Manual


Function lua_toboolean:Int (lua_state:Byte Ptr, index:Int)

Converts the Lua value at the given acceptable index to a boolean value (0 or 1).

See Lua Reference Manual


Function lua_tocfunction:Byte Ptr (lua_state:Byte Ptr, index:Int)

Converts a value at the given acceptable index to a function.

See Lua Reference Manual


Function lua_tolstring:Byte Ptr (lua_state:Byte Ptr, index:Int, size:Size_T Ptr) ' without any conversion!

Converts the Lua value at the given acceptable index to a C string.

See Lua Reference Manual


Function lua_tonumber:Double (lua_state:Byte Ptr, index:Int)

Converts the Lua value at the given acceptable index to the C type lua_Number.

See Lua Reference Manual


Function lua_topointer:Byte Ptr (lua_state:Byte Ptr, index:Int)

Converts the value at the given acceptable index to a generic C pointer.

See Lua Reference Manual


Function lua_tothread:Byte Ptr (lua_state:Byte Ptr, index:Int)

Converts the value at the given acceptable index to a Lua thread.

See Lua Reference Manual


Function lua_touserdata:Byte Ptr (lua_state:Byte Ptr, index:Int)

If the value at the given acceptable index is a full userdata, returns its block address.

See Lua Reference Manual


Function lua_type:Int (lua_state:Byte Ptr, index:Int)

Returns the type of the value in the given acceptable index, or LUA_TNONE for a non-valid index.

See Lua Reference Manual


Function lua_typename$z (lua_state:Byte Ptr, tp:Int)

Returns the name of the type encoded by the value tp, which must be one the values returned by lua_type.

See Lua Reference Manual


Function lua_xmove(fromState:Byte Ptr, toState:Byte Ptr, n:Int)

Exchange values between different threads of the same global state.

See Lua Reference Manual


Function lua_yield:Int (lua_state:Byte Ptr, nresults:Int)

Yields a coroutine.

See Lua Reference Manual


Function lua_isboolean:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index has type boolean, and 0 otherwise.

See Lua Reference Manual


Function lua_isfunction:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a function (either C or Lua), and 0 otherwise.

See Lua Reference Manual


Function lua_islightuserdata:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a light userdata, and 0 otherwise.

See Lua Reference Manual


Function lua_isnil:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is nil, and 0 otherwise.

See Lua Reference Manual


Function lua_isnone:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the given acceptable index is not valid (that is, it refers to an element outside the current stack), and 0 otherwise.

See Lua Reference Manual


Function lua_isnoneornil:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the given acceptable index is not valid (that is, it refers to an element outside the current stack) or if the value at this index is nil, and 0 otherwise.

See Lua Reference Manual


Function lua_istable:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a table, and 0 otherwise.

See Lua Reference Manual


Function lua_isthread:Int (lua_state:Byte Ptr, index:Int)

Returns 1 if the value at the given acceptable index is a thread, and 0 otherwise.

See Lua Reference Manual


Function lua_newtable (lua_state:Byte Ptr)

Creates a new empty table and pushes it onto the stack.

See Lua Reference Manual


Function lua_pop (lua_state:Byte Ptr, n:Int)

Pops n elements from the stack.

See Lua Reference Manual


Function lua_pushcfunction (lua_state:Byte Ptr, fn:Int(ls:Byte Ptr))

Pushes a function onto the stack.

See Lua Reference Manual


Function lua_register (lua_state:Byte Ptr, name:String, f:Int(ls:Byte Ptr))

Sets the function f as the new value of global name.

See Lua Reference Manual


Function lua_setglobal (lua_state:Byte Ptr, name:String)

Pops a value from the stack and sets it as the new value of global name.

See Lua Reference Manual


Function lua_tostring:String (lua_state:Byte Ptr, index:Int)

Equivalent to lua_tolstring with len equal to NULL.

See Lua Reference Manual


Function luaL_addlstring (B:Byte Ptr, s:Byte Ptr, l:Int)

Adds the string pointed to by s with length l to the buffer B.

See Lua Reference Manual


Function luaL_addsize (B:Byte Ptr, size:Int)

Adds to the buffer B (see luaL_Buffer) a string of length size previously copied to the buffer area

See Lua Reference Manual


Function luaL_addstring (B:Byte Ptr, s$z)

Adds the zero-terminated string pointed to by s to the buffer B.

See Lua Reference Manual


Function luaL_addvalue (B:Byte Ptr)

Adds the value at the top of the stack to the buffer B.

See Lua Reference Manual


Function luaL_argerror:Int (lua_state:Byte Ptr, narg:Int, extramsg$z)

Raises an error with the following message, where func is retrieved from the call stack.

See Lua Reference Manual


Function luaL_buffinit (lua_state:Byte Ptr, B:Byte Ptr)

Initializes a buffer B.

See Lua Reference Manual


Function luaL_callmeta:Int (lua_state:Byte Ptr, obj:Int, e$z)

Calls a metamethod.

See Lua Reference Manual


Function luaL_checkany (lua_state:Byte Ptr, narg:Int)

Checks whether the function has an argument of any type (including nil) at position narg.

See Lua Reference Manual


Function luaL_checklstring:Byte Ptr (lua_state:Byte Ptr, narg:Int, size:Int Ptr)

Checks whether the function argument narg is a string and returns this string.

See Lua Reference Manual


Function luaL_checknumber:Double (lua_state:Byte Ptr, narg:Int)

Checks whether the function argument narg is a number and returns this number.

See Lua Reference Manual


Function luaL_checkstack (lua_state:Byte Ptr, sz:Int, msg$z)

Grows the stack size to top + sz elements, raising an error if the stack cannot grow to that size.

See Lua Reference Manual


Function luaL_checktype (lua_state:Byte Ptr, narg:Int, t:Int)

Checks whether the function argument narg has type t.

See Lua Reference Manual


Function luaL_checkudata:Byte Ptr (lua_state:Byte Ptr, narg:Int, tname$z)

Checks whether the function argument narg is a userdata of the type tname.

See Lua Reference Manual


Function luaL_getmetafield:Int (lua_state:Byte Ptr, obj:Int, e$z)

Pushes onto the stack the field e from the metatable of the object at index obj.

See Lua Reference Manual


Function luaL_gsub$z (lua_state:Byte Ptr, s$z, p$z, r$z)

Creates a copy of string s by replacing any occurrence of the string p with the string r.

See Lua Reference Manual


Function luaL_loadbuffer:Int (lua_state:Byte Ptr, buff:Byte Ptr, sz:Int, name$z)

Loads a buffer as a Lua chunk.

See Lua Reference Manual


Function luaL_loadfile:Int (lua_state:Byte Ptr, filename$z)

Loads a file as a Lua chunk.

See Lua Reference Manual


Function luaL_loadstring:Int (lua_state:Byte Ptr, s$z)

Loads a string as a Lua chunk.

See Lua Reference Manual


Function luaL_newmetatable:Int (lua_state:Byte Ptr, tname$z)

If the registry already has the key tname, returns 0.

See Lua Reference Manual


Function luaL_newstate:Byte Ptr ()

Creates a new Lua state.

See Lua Reference Manual


Function luaL_openlibs (lua_state:Byte Ptr)

Opens all standard Lua libraries into the given state.

See Lua Reference Manual


Function luaL_optlstring:Byte Ptr (lua_state:Byte Ptr, narg:Int, d$z, size:Int Ptr)

If the function argument narg is a string, returns this string.

See Lua Reference Manual


Function luaL_optnumber:Double (lua_state:Byte Ptr, narg:Int, d:Double)

If the function argument narg is a number, returns this number.

See Lua Reference Manual


Function luaL_prepbuffer:Byte Ptr (B:Byte Ptr)

Returns an address to a space of size LUAL_BUFFERSIZE where you can copy a string to be added to buffer B.

See Lua Reference Manual


Function luaL_pushresult (B:Byte Ptr)

Finishes the use of buffer B leaving the final string on the top of the stack.

See Lua Reference Manual


Function luaL_ref:Int (lua_state:Byte Ptr, t:Int)

Creates and returns a reference, in the table at index t, for the object at the top of the stack (and pops the object).

See Lua Reference Manual


Function luaL_register (lua_state:Byte Ptr, libname$z, l:lua_Reg Ptr)

Opens a library.

See Lua Reference Manual


Function luaL_typerror:Int (lua_state:Byte Ptr, narg:Int, tname$z)

Generates an error with a message.

See Lua Reference Manual


Function luaL_unref (lua_state:Byte Ptr, t:Int, ref:Int)

Releases reference ref from the table at index t.

See Lua Reference Manual


Function luaL_where (lua_state:Byte Ptr, lvl:Int)

Pushes onto the stack a string identifying the current position of the control at level lvl in the call stack.

See Lua Reference Manual


Function luaL_addchar (B:Byte Ptr, c:String)

Adds the character c to the buffer B. (see luaL_Buffer).

See Lua Reference Manual


Function luaL_argcheck (lua_state:Byte Ptr, cond:Int, narg:Int, extramsg:String)

Checks whether cond is True.

See Lua Reference Manual


Function luaL_checkint:Int (lua_state:Byte Ptr, narg:Int)

Checks whether the function argument narg is a number and returns this number cast to an Int.

See Lua Reference Manual


Function luaL_checklong:Long (lua_state:Byte Ptr, narg:Int)

Checks whether the function argument narg is a number and returns this number cast to a Long.

See Lua Reference Manual


Function luaL_checkstring:String (lua_state:Byte Ptr, narg:Int)

Checks whether the function argument narg is a string and returns this string.

See Lua Reference Manual


Function luaL_dofile:Int (lua_state:Byte Ptr, filename:String)

Loads and runs the given file.

See Lua Reference Manual


Function luaL_dostring:Int (lua_state:Byte Ptr, str:String)

Loads and runs the given string.

See Lua Reference Manual


Function luaL_getmetatable (lua_state:Byte Ptr, tname:String)

Pushes onto the stack the metatable associated with name tname in the registry (see luaL_newmetatable).

See Lua Reference Manual


Function luaL_optint:Int (lua_state:Byte Ptr, narg:Int, d:Int)

If the function argument narg is a number, returns this number cast to an Int.

See Lua Reference Manual


Function luaL_optlong:Long (lua_state:Byte Ptr, narg:Int, d:Long)

If the function argument narg is a number, returns this number cast to a Long.

See Lua Reference Manual


Function luaL_optstring:String (lua_state:Byte Ptr, narg:Int, d:String)

If the function argument narg is a String, returns this String.

See Lua Reference Manual


Function luaL_typename:String (lua_state:Byte Ptr, idx:Int)

Returns the name of the type of the value at the given index.

See Lua Reference Manual


← TJoystickDriverPub.OpenAL →
  • Setting up a Lua VM
  • Shutting down a Lua VM
    • Accessing Lua Globals
  • Registering BlitzMax Functions
  • Running Lua Scripts From Within BlitzMax
  • Functions
    • Function lua_atpanic:Byte Ptr (lua_state:Byte Ptr, panicf:Int(ls:Byte Ptr))
    • Function lua_call (lua_state:Byte Ptr, nargs:Int, nresults:Int)
    • Function lua_checkstack:Int (lua_state:Byte Ptr, extra:Int)
    • Function lua_close (lua_state:Byte Ptr)
    • Function lua_concat (lua_state:Byte Ptr, n:Int)
    • Function lua_cpcall:Int (lua_state:Byte Ptr, func:Int(ls:Byte Ptr), ud:Byte Ptr)
    • Function lua_createtable (lua_state:Byte Ptr, narr:Int, nrec:Int)
    • Function lua_equal:Int (lua_state:Byte Ptr, index1:Int, index2:Int)
    • Function lua_error:Int (lua_state:Byte Ptr)
    • Function lua_gc:Int (lua_state:Byte Ptr, what:Int, data:Int)
    • Function lua_getallocf:Byte Ptr (lua_state:Byte Ptr, ud:Byte Ptr Ptr)
    • Function lua_getfenv (lua_state:Byte Ptr, index:Int)
    • Function lua_getfield (lua_state:Byte Ptr, index:Int, k$z)
    • Function lua_gethook:Byte Ptr (lua_state:Byte Ptr)
    • Function lua_gethookcount:Int (lua_state:Byte Ptr)
    • Function lua_gethookmask:Int (lua_state:Byte Ptr)
    • Function lua_getinfo:Int (lua_state:Byte Ptr, what$z, ar:lua_Debug Ptr)
    • Function lua_getlocal$z (lua_state:Byte Ptr, ar:lua_Debug Ptr, n:Int)
    • Function lua_getmetatable:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_getstack:Int (lua_state:Byte Ptr, level:Int, ar:lua_Debug Ptr)
    • Function lua_gettable (lua_state:Byte Ptr, index:Int)
    • Function lua_gettop:Int (lua_state:Byte Ptr)
    • Function lua_getupvalue$z (lua_state:Byte Ptr, funcindex:Int, n:Int)
    • Function lua_insert (lua_state:Byte Ptr, index:Int)
    • Function lua_iscfunction:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isnumber:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isstring:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isuserdata:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_lessthan:Int (lua_state:Byte Ptr, index1:Int, index2:Int)
    • Function lua_newthread:Byte Ptr (lua_state:Byte Ptr)
    • Function lua_next:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_pcall:Int (lua_state:Byte Ptr, nargs:Int, nresults:Int, errfunc:Int)
    • Function lua_pushboolean (lua_state:Byte Ptr, b:Int)
    • Function lua_pushcclosure (lua_state:Byte Ptr, fn:Int(ls:Byte Ptr), n:Int)
    • Function lua_pushlightuserdata (lua_state:Byte Ptr, p:Byte Ptr)
    • Function lua_pushnil (lua_state:Byte Ptr)
    • Function lua_pushnumber (lua_state:Byte Ptr, n:Double)
    • Function lua_pushstring (lua_state:Byte Ptr, s$z)
    • Function lua_pushthread:Int (lua_state:Byte Ptr)
    • Function lua_pushvalue (lua_state:Byte Ptr, index:Int)
    • Function lua_rawequal:Int (lua_state:Byte Ptr, index1:Int, index2:Int)
    • Function lua_rawget (lua_state:Byte Ptr, index:Int)
    • Function lua_rawgeti (lua_state:Byte Ptr, index:Int, n:Int)
    • Function lua_rawset (lua_state:Byte Ptr, index:Int)
    • Function lua_rawseti (lua_state:Byte Ptr, index:Int, n:Int)
    • Function lua_remove (lua_state:Byte Ptr, index:Int)
    • Function lua_replace (lua_state:Byte Ptr, index:Int)
    • Function lua_resume:Int (lua_state:Byte Ptr, narg:Int)
    • Function lua_setfenv:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_setfield (lua_state:Byte Ptr, index:Int, k$z)
    • Function lua_sethook:Int (lua_state:Byte Ptr, f(ls:Byte Ptr,ar:lua_Debug Ptr), mask:Int, count:Int)
    • Function lua_setlocal$z (lua_state:Byte Ptr, ar:lua_Debug Ptr, n:Int)
    • Function lua_setmetatable:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_settable (lua_state:Byte Ptr, index:Int)
    • Function lua_settop (lua_state:Byte Ptr, index:Int)
    • Function lua_setupvalue$z (lua_state:Byte Ptr, funcindex:Int, n:Int)
    • Function lua_status:Int (lua_state:Byte Ptr)
    • Function lua_toboolean:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_tocfunction:Byte Ptr (lua_state:Byte Ptr, index:Int)
    • Function lua_tolstring:Byte Ptr (lua_state:Byte Ptr, index:Int, size:Size_T Ptr) ' without any conversion!
    • Function lua_tonumber:Double (lua_state:Byte Ptr, index:Int)
    • Function lua_topointer:Byte Ptr (lua_state:Byte Ptr, index:Int)
    • Function lua_tothread:Byte Ptr (lua_state:Byte Ptr, index:Int)
    • Function lua_touserdata:Byte Ptr (lua_state:Byte Ptr, index:Int)
    • Function lua_type:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_typename$z (lua_state:Byte Ptr, tp:Int)
    • Function lua_xmove(fromState:Byte Ptr, toState:Byte Ptr, n:Int)
    • Function lua_yield:Int (lua_state:Byte Ptr, nresults:Int)
    • Function lua_isboolean:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isfunction:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_islightuserdata:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isnil:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isnone:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isnoneornil:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_istable:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_isthread:Int (lua_state:Byte Ptr, index:Int)
    • Function lua_newtable (lua_state:Byte Ptr)
    • Function lua_pop (lua_state:Byte Ptr, n:Int)
    • Function lua_pushcfunction (lua_state:Byte Ptr, fn:Int(ls:Byte Ptr))
    • Function lua_register (lua_state:Byte Ptr, name:String, f:Int(ls:Byte Ptr))
    • Function lua_setglobal (lua_state:Byte Ptr, name:String)
    • Function lua_tostring:String (lua_state:Byte Ptr, index:Int)
    • Function luaL_addlstring (B:Byte Ptr, s:Byte Ptr, l:Int)
    • Function luaL_addsize (B:Byte Ptr, size:Int)
    • Function luaL_addstring (B:Byte Ptr, s$z)
    • Function luaL_addvalue (B:Byte Ptr)
    • Function luaL_argerror:Int (lua_state:Byte Ptr, narg:Int, extramsg$z)
    • Function luaL_buffinit (lua_state:Byte Ptr, B:Byte Ptr)
    • Function luaL_callmeta:Int (lua_state:Byte Ptr, obj:Int, e$z)
    • Function luaL_checkany (lua_state:Byte Ptr, narg:Int)
    • Function luaL_checklstring:Byte Ptr (lua_state:Byte Ptr, narg:Int, size:Int Ptr)
    • Function luaL_checknumber:Double (lua_state:Byte Ptr, narg:Int)
    • Function luaL_checkstack (lua_state:Byte Ptr, sz:Int, msg$z)
    • Function luaL_checktype (lua_state:Byte Ptr, narg:Int, t:Int)
    • Function luaL_checkudata:Byte Ptr (lua_state:Byte Ptr, narg:Int, tname$z)
    • Function luaL_getmetafield:Int (lua_state:Byte Ptr, obj:Int, e$z)
    • Function luaL_gsub$z (lua_state:Byte Ptr, s$z, p$z, r$z)
    • Function luaL_loadbuffer:Int (lua_state:Byte Ptr, buff:Byte Ptr, sz:Int, name$z)
    • Function luaL_loadfile:Int (lua_state:Byte Ptr, filename$z)
    • Function luaL_loadstring:Int (lua_state:Byte Ptr, s$z)
    • Function luaL_newmetatable:Int (lua_state:Byte Ptr, tname$z)
    • Function luaL_newstate:Byte Ptr ()
    • Function luaL_openlibs (lua_state:Byte Ptr)
    • Function luaL_optlstring:Byte Ptr (lua_state:Byte Ptr, narg:Int, d$z, size:Int Ptr)
    • Function luaL_optnumber:Double (lua_state:Byte Ptr, narg:Int, d:Double)
    • Function luaL_prepbuffer:Byte Ptr (B:Byte Ptr)
    • Function luaL_pushresult (B:Byte Ptr)
    • Function luaL_ref:Int (lua_state:Byte Ptr, t:Int)
    • Function luaL_register (lua_state:Byte Ptr, libname$z, l:lua_Reg Ptr)
    • Function luaL_typerror:Int (lua_state:Byte Ptr, narg:Int, tname$z)
    • Function luaL_unref (lua_state:Byte Ptr, t:Int, ref:Int)
    • Function luaL_where (lua_state:Byte Ptr, lvl:Int)
    • Function luaL_addchar (B:Byte Ptr, c:String)
    • Function luaL_argcheck (lua_state:Byte Ptr, cond:Int, narg:Int, extramsg:String)
    • Function luaL_checkint:Int (lua_state:Byte Ptr, narg:Int)
    • Function luaL_checklong:Long (lua_state:Byte Ptr, narg:Int)
    • Function luaL_checkstring:String (lua_state:Byte Ptr, narg:Int)
    • Function luaL_dofile:Int (lua_state:Byte Ptr, filename:String)
    • Function luaL_dostring:Int (lua_state:Byte Ptr, str:String)
    • Function luaL_getmetatable (lua_state:Byte Ptr, tname:String)
    • Function luaL_optint:Int (lua_state:Byte Ptr, narg:Int, d:Int)
    • Function luaL_optlong:Long (lua_state:Byte Ptr, narg:Int, d:Long)
    • Function luaL_optstring:String (lua_state:Byte Ptr, narg:Int, d:String)
    • Function luaL_typename:String (lua_state:Byte Ptr, idx:Int)
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson