Add gControllers

This commit is contained in:
Agent X 2024-01-01 14:43:44 -05:00
parent 37cfd9ae04
commit 6886f248f8
3 changed files with 21 additions and 0 deletions

View file

@ -23,6 +23,9 @@ gActiveMods = {}
--- @type Character[]
gCharacters = {}
--- @type Controller[]
gControllers = {}
--- @type GlobalTextures
gTextures = {}

View file

@ -37,6 +37,13 @@ The `gCharacters[]` table is an array from `0` to `(CT_MAX - 1)` that contains a
<br />
## [gControllers](#gControllers)
The `gControllers[]` table is an array from `0` to `(MAX_PLAYERS - 1)` that contains a [Controller](structs.md#Controller) struct for each possible player.
[:arrow_up_small:](#)
<br />
## [gTextures](#gTextures)
The `gTextures` table contains references to textures. Listed in [GlobalTextures](structs.md#GlobalTextures).

View file

@ -603,6 +603,17 @@ void smlua_cobject_init_globals(void) {
lua_setglobal(L, "gCharacters");
}
{
lua_newtable(L);
int t = lua_gettop(gLuaState);
for (s32 i = 0; i < MAX_PLAYERS; i++) {
lua_pushinteger(L, i);
smlua_push_object(L, LOT_CONTROLLER, &gControllers[i]);
lua_settable(L, t);
}
lua_setglobal(L, "gControllers");
}
#define EXPOSE_GLOBAL(lot, ptr) \
{ \
smlua_push_object(L, lot, &ptr); \