From 42ec654f3e38e8c037a948665d96789334f5b3d1 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 16 Sep 2012 12:01:48 +0100 Subject: [PATCH] When reloading elements API, set packages.loaded["elements"] to nil to prevent luaL_register from trying to reuse a nilled table. Fixes #189 --- src/cat/LuaScriptInterface.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 87496ec6e..98bd5ba4f 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(); }