From 71cceaaf3c4bd509a4a4a74a1873843b9f261c17 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 28 Mar 2021 23:10:30 +0100 Subject: [PATCH] Readded Kartstuff and Karthud access to Lua, resolving both #143 and #138. --- src/deh_lua.c | 36 ++++++++++++++++++++++++++++++++++++ src/deh_tables.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/src/deh_lua.c b/src/deh_lua.c index 99c00ca33..c36ebc034 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -463,6 +463,42 @@ static inline int lib_getenum(lua_State *L) } return luaL_error(L, "power '%s' could not be found.\n", word); } + else if (!mathlib && fastncmp("k_",word,2)) { + p = word+2; + for (i = 0; i < NUMKARTSTUFF; i++) + if (fasticmp(p, KARTSTUFF_LIST[i])) { + lua_pushinteger(L, i); + return 1; + } + return 0; + } + else if (mathlib && fastncmp("K_",word,2)) { // SOCs are ALL CAPS! + p = word+2; + for (i = 0; i < NUMKARTSTUFF; i++) + if (fastcmp(p, KARTSTUFF_LIST[i])) { + lua_pushinteger(L, i); + return 1; + } + return luaL_error(L, "kartstuff '%s' could not be found.\n", word); + } + else if (!mathlib && fastncmp("khud_",word,5)) { + p = word+5; + for (i = 0; i < NUMKARTHUD; i++) + if (fasticmp(p, KARTHUD_LIST[i])) { + lua_pushinteger(L, i); + return 1; + } + return 0; + } + else if (mathlib && fastncmp("KHUD_",word,5)) { // SOCs are ALL CAPS! + p = word+5; + for (i = 0; i < NUMKARTHUD; i++) + if (fastcmp(p, KARTHUD_LIST[i])) { + lua_pushinteger(L, i); + return 1; + } + return luaL_error(L, "karthud '%s' could not be found.\n", word); + } else if (fastncmp("HUD_",word,4)) { p = word+4; for (i = 0; i < NUMHUDITEMS; i++) diff --git a/src/deh_tables.h b/src/deh_tables.h index d094bcbad..53c52fbfa 100644 --- a/src/deh_tables.h +++ b/src/deh_tables.h @@ -67,6 +67,8 @@ extern const char *const GAMETYPERULE_LIST[]; extern const char *const ML_LIST[16]; // Linedef flags extern const char *COLOR_ENUMS[]; extern const char *const POWERS_LIST[]; +extern const char *const KARTSTUFF_LIST[]; +extern const char *const KARTHUD_LIST[]; extern const char *const HUDITEMS_LIST[]; extern const char *const MENUTYPES_LIST[];