PT 2 of Kartstuff->Player_t mapping, setter

This commit is contained in:
NepDisk 2024-12-27 17:43:03 -05:00
parent e406da29c8
commit 2d573e1923
2 changed files with 16 additions and 5 deletions

View file

@ -513,8 +513,8 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
if (mathlib) return luaL_error(L, "sfx '%s' could not be found.\n", word);
return 0;
}
else if (!mathlib && fastncmp("k_",word,5)) {
p = word+5;
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);
@ -522,8 +522,8 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
}
return 0;
}
else if (mathlib && fastncmp("K_",word,5)) { // SOCs are ALL CAPS!
p = word+5;
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);

View file

@ -910,6 +910,7 @@ static int kartstuff_get(lua_State *L)
static int kartstuff_set(lua_State *L)
{
INT32 *kartstuff = *((INT32 **)luaL_checkudata(L, 1, META_KARTSTUFF));
player_t *plr = (player_t*)(kartstuff - offsetof(player_t, kartstuff));
kartstufftype_t ks = luaL_checkinteger(L, 2);
INT32 i = (INT32)luaL_checkinteger(L, 3);
@ -919,7 +920,17 @@ static int kartstuff_set(lua_State *L)
return luaL_error(L, "Do not alter player_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter player_t in CMD building code!");
kartstuff[ks] = i;
switch (ks)
{
case k_sneakertimer:
plr->sneakertimer = i;
break;
default:
return luaL_error(L, LUA_QL("kartstufftype_t") " cannot be %u", ks);
}
return 0;
}