Readded Kartstuff and Karthud access to Lua, resolving both #143 and #138.

This commit is contained in:
toaster 2021-03-28 23:10:30 +01:00
parent 4e3b4a82f9
commit 71cceaaf3c
2 changed files with 38 additions and 0 deletions

View file

@ -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++)

View file

@ -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[];