User:Monster Iestyn/Source Code Documentation/lua_libs.h
Appearance
Online link | GitHub entry |
---|---|
File type | C header file |
#include guard | none |
This header file contains prototypes of the functions that initialise SRB2's internal libraries for Lua scripting. Also included is the global Lua state variable, and some macros for indexing the Lua registry.
Externs
Data name | Data type | Non-extern location(s) | Description |
---|---|---|---|
*gL
|
lua_State
|
lua_script.c
|
The global Lua state for SRB2. If the Lua scripting interface has not been initialized yet, this will be NULL. |
Macros
Lua registry indexes
In SRB2, several special tables of data are created and stored within the Lua registry, using the below macros as their indexes within it.
Macro | Defined as | Description |
---|---|---|
LREG_VALID
|
"VALID_USERDATA"
|
Index of valid userdata pointers |
LREG_EXTVARS
|
"LUA_VARS"
|
Index of extra variables for userdata (mobj_t , player_t and mobjinfo_t only)
|
LREG_STATEACTION
|
"STATE_ACTION"
|
Index of A_Lua actions to run for each state
|
LREG_ACTIONS
|
"MOBJ_ACTION"
|
Index of globally available actions, by function name |
Userdata metatable indexes
The metatables defined for each type of Lua userdata used in SRB2 are stored in the Lua registry, using the below macros as their indexes within it.
Macro | Defined as | Description |
---|---|---|
META_STATE
|
"STATE_T*"
|
state_t metatable |
META_MOBJINFO
|
"MOBJINFO_T*"
|
mobjinfo_t metatable |
META_SFXINFO
|
"SFXINFO_T*"
|
sfxinfo_t metatable |
META_MOBJ
|
"MOBJ_T*"
|
mobj_t metatable |
META_MAPTHING
|
"MAPTHING_T*"
|
mapthing_t metatable |
META_PLAYER
|
"PLAYER_T*"
|
player_t metatable |
META_TICCMD
|
"TICCMD_T*"
|
ticcmd_t metatable |
META_SKIN
|
"SKIN_T*"
|
skin_t metatable |
META_POWERS
|
"PLAYER_T*POWERS"
|
player.powers metatable
|
META_SOUNDSID
|
"SKIN_T*SOUNDSID"
|
skin.soundsid metatable
|
META_VERTEX
|
"VERTEX_T*"
|
vertex_t metatable |
META_LINE
|
"LINE_T*"
|
line_t metatable |
META_SIDE
|
"SIDE_T*"
|
side_t metatable |
META_SUBSECTOR
|
"SUBSECTOR_T*"
|
subsector_t metatable |
META_SECTOR
|
"SECTOR_T*"
|
sector_t metatable |
META_FFLOOR
|
"FFLOOR_T*"
|
ffloor_t metatable |
META_SLOPE
|
"PSLOPE_T*"
|
Defined only if ESLOPE is defined
pslope_t metatable |
META_VECTOR2
|
"VECTOR2_T*"
|
Defined only if ESLOPE is defined
vector2_t metatable |
META_VECTOR3
|
"VECTOR3_T*"
|
Defined only if ESLOPE is defined
vector3_t metatable |
META_MAPHEADER
|
"MAPHEADER_T*"
|
mapheader_t metatable |
META_CVAR
|
"CONSVAR_T*"
|
consvar_t metatable |
META_SECTORLINES
|
"SECTOR_T*LINES"
|
sector.lines metatable
|
META_SIDENUM
|
"LINE_T*SIDENUM"
|
line.sidenum metatable
|
META_HUDINFO
|
"HUDINFO_T*"
|
hudinfo_t metatable |
META_PATCH
|
"PATCH_T*"
|
patch_t metatable |
META_COLORMAP
|
"COLORMAP"
|
colormap (UINT8 array) metatable |
META_CAMERA
|
"CAMERA_T*"
|
camera_t metatable |
Function prototypes
Function name | Return type | Params | Defined in | Description |
---|---|---|---|---|
luaL_checkboolean
|
boolean | lua_State *L ,int narg
|
lua_baselib.c
|
Checks if the value at index narg in the Lua stack is a boolean, and returns it if it is. If it is not, a Lua error is generated.
|
LUA_EnumLib
|
int | lua_State *L
|
dehacked.c
|
Opens the Enum library (sets up the global metatable for enums and constants; also covers dynamic variables, super and actions)
|
LUA_SOCLib
|
int | lua_State *L
|
dehacked.c
|
Opens the SOC library (registers the freeslot function)
|
LUA_BaseLib
|
int | lua_State *L
|
lua_baselib.c
|
Opens the Base library (string concatination by +; setup of LREG_EXTVARS index; registers the Base library functions)
|
LUA_MathLib
|
int | lua_State *L
|
lua_mathlib.c
|
Opens the Math library (registers the Math library functions) |
LUA_HookLib
|
int | lua_State *L
|
lua_hooklib.c
|
Opens the Hook library (initialises hooksAvailable ; registers the addHook function)
|
LUA_ConsoleLib
|
int | lua_State *L
|
lua_consolelib.c
|
Opens the Console library (consvar_t metatable; setup of console command/consvar registry tables; registers the Console library functions)
|
LUA_InfoLib
|
int | lua_State *L
|
lua_infolib.c
|
Opens the Info library (setup of LREG_STATEACTION , LREG_ACTIONS indexes; state_t , mobjinfo_t , sfxinfo_t metatables; sprnames[] , states[] , mobjinfo[] , sfxinfo[] metatables)
|
LUA_MobjLib
|
int | lua_State *L
|
lua_mobjlib.c
|
Opens the Mobj library (mobj_t , mapthing_t metatables; mapthings[] metatable)
|
LUA_PlayerLib
|
int | lua_State *L
|
lua_playerlib.c
|
Opens the Player library (player_t , player.powers[] , ticcmd_t metatables; players[] metatable)
|
LUA_SkinLib
|
int | lua_State *L
|
lua_skinlib.c
|
Opens the Skin library (skin_t , skin.soundsid[] metatables; skins[] metatable)
|
LUA_ThinkerLib
|
int | lua_State *L
|
lua_thinkerlib.c
|
Opens the Thinker library (thinkers metatable)
|
LUA_MapLib
|
int | lua_State *L
|
lua_maplib.c
|
Opens the Map library (sector_t , sector.lines[] , subsector_t , line_t , line.sidenum[] , side_t , vertex_t , ffloor_t , mapheader_t ; sectors[] , subsectors[] , lines[] , sides[] , vertexes[] , mapheaderinfo[] metatables)
|
LUA_BlockmapLib
|
int | lua_State *L
|
lua_blockmaplib.c
|
Opens the Blockmap search library (searchBlockmap )
|
LUA_HudLib
|
int | lua_State *L
|
lua_hudlib.c
|
Opens the HUD library (initialises hud_enabled ; setup of HUD registry table; hudinfo , colormap, patch_t , camera_t metatables; hudinfo[] metatable)
|