summaryrefslogtreecommitdiff
path: root/src/cat/LuaScriptInterface.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-16 11:01:48 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-16 11:01:48 (GMT)
commit42ec654f3e38e8c037a948665d96789334f5b3d1 (patch)
treefc689a490d6e46d1d061abcd5857e4ba9a40c3ca /src/cat/LuaScriptInterface.cpp
parent8a4d18df49f6dbc22b3c1b87c19cc7e6eca5837b (diff)
downloadpowder-42ec654f3e38e8c037a948665d96789334f5b3d1.zip
powder-42ec654f3e38e8c037a948665d96789334f5b3d1.tar.gz
When reloading elements API, set packages.loaded["elements"] to nil to prevent luaL_register from trying to reuse a nilled table. Fixes #189
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
-rw-r--r--src/cat/LuaScriptInterface.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 87496ec..98bd5ba 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -725,6 +725,14 @@ int LuaScriptInterface::elements_loadDefault(lua_State * l)
}
lua_pushnil(l);
lua_setglobal(l, "elements");
+ lua_pushnil(l);
+ lua_setglobal(l, "elem");
+
+ lua_getglobal(l, "package");
+ lua_getfield(l, -1, "loaded");
+ lua_pushnil(l);
+ lua_setfield(l, -2, "elements");
+
luacon_ci->initElementsAPI();
}