diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-05-30 22:40:43 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-05-30 22:40:43 +0200 |
commit | 2eb1240e14986e1cccc02a96713133a003347f8b (patch) | |
tree | 28c58a677423d507ab57e421b9fcb8df8b31c5e0 /source/Plugin_NewLua.cpp | |
parent | Window contents are sent whenever the window is opened by a player. (diff) | |
download | cuberite-2eb1240e14986e1cccc02a96713133a003347f8b.tar cuberite-2eb1240e14986e1cccc02a96713133a003347f8b.tar.gz cuberite-2eb1240e14986e1cccc02a96713133a003347f8b.tar.bz2 cuberite-2eb1240e14986e1cccc02a96713133a003347f8b.tar.lz cuberite-2eb1240e14986e1cccc02a96713133a003347f8b.tar.xz cuberite-2eb1240e14986e1cccc02a96713133a003347f8b.tar.zst cuberite-2eb1240e14986e1cccc02a96713133a003347f8b.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Plugin_NewLua.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp index df18cfa9b..dd3db7d6a 100644 --- a/source/Plugin_NewLua.cpp +++ b/source/Plugin_NewLua.cpp @@ -1665,6 +1665,30 @@ void cPlugin_NewLua::Unreference(int a_LuaRef) +bool cPlugin_NewLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player) +{ + cCSLock Lock(m_CriticalSection); + lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_FnRef); // Push the function to be called + tolua_pushusertype(m_LuaState, &a_Window, "cWindow"); + tolua_pushusertype(m_LuaState, &a_Player, "cPlayer"); + + // Call function: + int s = lua_pcall(m_LuaState, 2, 1, 0); + if (report_errors(m_LuaState, s)) + { + LOGERROR("LUA error in %s. Stack size: %i", __FUNCTION__, lua_gettop(m_LuaState)); + return false; + } + + bool bRetVal = (tolua_toboolean(m_LuaState, -1, false) > 0); + lua_pop(m_LuaState, 1); + return bRetVal; +} + + + + + // Helper functions bool cPlugin_NewLua::PushFunction(const char * a_FunctionName, bool a_bLogError /* = true */) { |