Push musname_size and musname to Lua (correctly, this time)

This commit is contained in:
wolfy852 2023-02-10 01:02:34 -06:00
parent 79a921f59b
commit 3ad0b6fd96

View file

@ -2508,12 +2508,22 @@ static int mapheaderinfo_get(lua_State *L)
lua_pushinteger(L, header->typeoflevel); lua_pushinteger(L, header->typeoflevel);
else if (fastcmp(field,"keywords")) else if (fastcmp(field,"keywords"))
lua_pushstring(L, header->keywords); lua_pushstring(L, header->keywords);
else if (fastcmp(field,"musname")) else if (fastcmp(field,"musname")) // we create a table here because it saves us from a userdata nightmare
lua_pushstring(L, header->musname); {
UINT8 i;
lua_createtable(L, header->musname_size, 0);
for (i = 0; i < header->musname_size; i++)
{
lua_pushstring(L, header->musname[i]);
lua_rawseti(L, -2, 1 + i);
}
}
else if (fastcmp(field,"mustrack")) else if (fastcmp(field,"mustrack"))
lua_pushinteger(L, header->mustrack); lua_pushinteger(L, header->mustrack);
else if (fastcmp(field,"muspos")) else if (fastcmp(field,"muspos"))
lua_pushinteger(L, header->muspos); lua_pushinteger(L, header->muspos);
else if (fastcmp(field,"musname_size"))
lua_pushinteger(L, header->musname_size);
else if (fastcmp(field,"weather")) else if (fastcmp(field,"weather"))
lua_pushinteger(L, header->weather); lua_pushinteger(L, header->weather);
else if (fastcmp(field,"skytexture")) else if (fastcmp(field,"skytexture"))
@ -2774,6 +2784,14 @@ int LUA_MapLib(lua_State *L)
//lua_pushcfunction(L, mapheaderinfo_num); //lua_pushcfunction(L, mapheaderinfo_num);
//lua_setfield(L, -2, "__len"); //lua_setfield(L, -2, "__len");
lua_pop(L, 1); lua_pop(L, 1);
/* luaL_newmetatable(L, META_MUSNAME);
lua_pushcfunction(L, musname_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, musname_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);*/
luaL_newmetatable(L, META_ACTIVATOR); luaL_newmetatable(L, META_ACTIVATOR);
lua_pushcfunction(L, activator_get); lua_pushcfunction(L, activator_get);