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[] --- @type Character[]
gCharacters = {} gCharacters = {}
--- @type Controller[]
gControllers = {}
--- @type GlobalTextures --- @type GlobalTextures
gTextures = {} gTextures = {}

View File

@ -37,6 +37,13 @@ The `gCharacters[]` table is an array from `0` to `(CT_MAX - 1)` that contains a
<br /> <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) ## [gTextures](#gTextures)
The `gTextures` table contains references to textures. Listed in [GlobalTextures](structs.md#GlobalTextures). 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_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) \ #define EXPOSE_GLOBAL(lot, ptr) \
{ \ { \
smlua_push_object(L, lot, &ptr); \ smlua_push_object(L, lot, &ptr); \