summaryrefslogtreecommitdiff
path: root/Examples/lua/embed3/embed3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/lua/embed3/embed3.cpp')
-rw-r--r--Examples/lua/embed3/embed3.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp
index e5e0e0a7d..cdf56268d 100644
--- a/Examples/lua/embed3/embed3.cpp
+++ b/Examples/lua/embed3/embed3.cpp
@@ -26,11 +26,15 @@ extern "C" {
#include <lauxlib.h>
#include <lualib.h>
}
-
-/* The SWIG external runtime is generated by using.
-swig -lua -externalruntime swigluarun.h
-It contains useful function used by SWIG in its wrappering
-SWIG_TypeQuery() SWIG_NewPointerObj()
+
+#if LUA_VERSION_NUM > 501
+#define lua_open luaL_newstate
+#endif
+
+/* The SWIG external runtime is generated by using.
+swig -lua -externalruntime swigluarun.h
+It contains useful function used by SWIG in its wrappering
+SWIG_TypeQuery() SWIG_NewPointerObj()
*/
#include "swigluarun.h" // the SWIG external runtime
@@ -65,8 +69,7 @@ int call_onEvent(lua_State *L, Event e) {
push a, push b, call 'add' check & return res
*/
top = lua_gettop(L); /* for later */
- lua_pushstring(L, "onEvent"); /* function name */
- lua_gettable(L, LUA_GLOBALSINDEX); /* function to be called */
+ lua_getglobal(L, "onEvent"); /* function to be called */
if (!lua_isfunction(L, -1)) {
printf("[C++] error: cannot find function 'OnEvent'\n");
lua_settop(L, top); // reset