From 380055cd1c6cde685853284e9d6c717e2889efd9 Mon Sep 17 00:00:00 2001 From: Guil Date: Thu, 6 Nov 2025 01:10:10 +0000 Subject: [PATCH 1/3] Expose localplayers to lua --- src/lua_playerlib.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 0f4f0ee6a..c5baf3c93 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -164,6 +164,74 @@ static int lib_lenDisplayplayers(lua_State *L) return 1; } +// Same deal as the three functions above but for localplayers +// don't gotta fix what ain't broken + +static int lib_iterateLocalplayers(lua_State *L) +{ + INT32 i = lua_tonumber(L, lua_upvalueindex(1)); + + if (lua_gettop(L) < 2) + { + lua_pushcclosure(L, lib_iterateLocalplayers, 1); + return 1; + } + + if (i <= r_splitscreen) + { + if (!playeringame[g_localplayers[i]] || (i > 0 && g_localplayers[i] == g_localplayers[0])) + return 0; + + // Return player and splitscreen index. + LUA_PushUserdata(L, &players[g_localplayers[i]], META_PLAYER); + lua_pushnumber(L, i); + + // Update splitscreen index value for next iteration. + lua_pushnumber(L, i + 1); + lua_pushvalue(L, -1); + lua_replace(L, lua_upvalueindex(1)); + lua_pop(L, 1); + + return 2; + } + return 0; +} + +static int lib_getLocalplayers(lua_State *L) +{ + const char *field; + // i -> players[i] + if (lua_type(L, 2) == LUA_TNUMBER) + { + lua_Integer i = luaL_checkinteger(L, 2); + if (i < 0 || i >= MAXSPLITSCREENPLAYERS) + return luaL_error(L, "localplayers[] index %d out of range (0 - %d)", i, MAXSPLITSCREENPLAYERS-1); + if (i > r_splitscreen) + return 0; + if (i > 0 && g_localplayers[i] == g_localplayers[0]) + return 0; + if (!playeringame[g_localplayers[i]]) + return 0; + LUA_PushUserdata(L, &players[g_localplayers[i]], META_PLAYER); + return 1; + } + + field = luaL_checkstring(L, 2); + if (fastcmp(field,"iterate")) + { + lua_pushcclosure(L, lib_iterateLocalplayers, 1); + return 1; + } + return 0; +} + +// #localplayers -> MAXSPLITSCREENPLAYERS +static int lib_lenLocalplayers(lua_State *L) +{ + lua_pushinteger(L, MAXSPLITSCREENPLAYERS); + return 1; +} + enum player_e { player_valid, @@ -3015,6 +3083,17 @@ int LUA_PlayerLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_setmetatable(L, -2); lua_setglobal(L, "displayplayers"); + + // ditto with localplayers + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getLocalplayers); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_lenLocalplayers); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "localplayers"); return 0; } From 7d183009236eb99f0dc8c75818195bbfbb8cd076 Mon Sep 17 00:00:00 2001 From: Guil Date: Thu, 6 Nov 2025 22:07:45 +0000 Subject: [PATCH 2/3] Expose localplayers to lua --- src/lua_playerlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index c5baf3c93..5e24f9aba 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -177,7 +177,7 @@ static int lib_iterateLocalplayers(lua_State *L) return 1; } - if (i <= r_splitscreen) + if (i <= splitscreen) { if (!playeringame[g_localplayers[i]] || (i > 0 && g_localplayers[i] == g_localplayers[0])) return 0; @@ -206,7 +206,7 @@ static int lib_getLocalplayers(lua_State *L) lua_Integer i = luaL_checkinteger(L, 2); if (i < 0 || i >= MAXSPLITSCREENPLAYERS) return luaL_error(L, "localplayers[] index %d out of range (0 - %d)", i, MAXSPLITSCREENPLAYERS-1); - if (i > r_splitscreen) + if (i > splitscreen) return 0; if (i > 0 && g_localplayers[i] == g_localplayers[0]) return 0; From 3c80deb60a5689d2f07d3632f949f588b1c15bca Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 17 Nov 2025 20:08:50 -0500 Subject: [PATCH 3/3] Update credits --- src/f_finale.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/f_finale.c b/src/f_finale.c index fb673c7aa..372b6908e 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -919,6 +919,8 @@ const char *blancredits[] = { "\"JugadorXEI\"", "\"Kimberly\"", "\"Chearii\"", + "\"hayaunderscore\" aka \"DeltaKaynx\"", + "\"Guilmon35249vr\"", "", "\1Item Design", "\"NepDisk\"",