Fixed the table inheritance which was backwards

This commit is contained in:
2016-04-11 00:08:42 +10:00
parent 752f8f82f9
commit 8e7af9ce88
4 changed files with 25 additions and 18 deletions
+6 -6
View File
@@ -76,27 +76,27 @@ static const luaL_Reg creatureLib[] = {
};
LUAMOD_API int openCreatureAPI(lua_State* L) {
//get the parent table
luaL_requiref(L, TORTUGA_ENTITY_API, openEntityAPI, false);
//the local table
luaL_newlib(L, creatureLib);
//merge the local table into the parent table
//get the parent table
luaL_requiref(L, TORTUGA_ENTITY_API, openEntityAPI, false);
//merge the parent table into the local table
lua_pushnil(L); //first key
while(lua_next(L, -2)) {
//copy the key-value pair
lua_pushvalue(L, -2);
lua_pushvalue(L, -2);
//push the copy to the parent table
//push the copy to the local table
lua_settable(L, -6);
//pop the original value before continuing
lua_pop(L, 1);
}
//remove the local table, leaving the expanded parent table
//remove the parent table, leaving the expanded local table
lua_pop(L, 1);
return 1;