summaryrefslogtreecommitdiffstats
path: root/source/Plugin_NewLua.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-31 09:16:14 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-31 09:16:14 +0200
commitbf7c2fe783133cd9f15d96981053ef7ab6aaf49a (patch)
tree3c30a01cd8690a59af2db1ee440bf7e8d2bc61f4 /source/Plugin_NewLua.cpp
parentAdded the OnClosing callback to cLuaWindow API (diff)
downloadcuberite-bf7c2fe783133cd9f15d96981053ef7ab6aaf49a.tar
cuberite-bf7c2fe783133cd9f15d96981053ef7ab6aaf49a.tar.gz
cuberite-bf7c2fe783133cd9f15d96981053ef7ab6aaf49a.tar.bz2
cuberite-bf7c2fe783133cd9f15d96981053ef7ab6aaf49a.tar.lz
cuberite-bf7c2fe783133cd9f15d96981053ef7ab6aaf49a.tar.xz
cuberite-bf7c2fe783133cd9f15d96981053ef7ab6aaf49a.tar.zst
cuberite-bf7c2fe783133cd9f15d96981053ef7ab6aaf49a.zip
Diffstat (limited to 'source/Plugin_NewLua.cpp')
-rw-r--r--source/Plugin_NewLua.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp
index dd3db7d6a..a76b51806 100644
--- a/source/Plugin_NewLua.cpp
+++ b/source/Plugin_NewLua.cpp
@@ -1667,6 +1667,8 @@ void cPlugin_NewLua::Unreference(int a_LuaRef)
bool cPlugin_NewLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player)
{
+ ASSERT(a_FnRef != LUA_REFNIL);
+
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");
@@ -1689,6 +1691,27 @@ bool cPlugin_NewLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPla
+void cPlugin_NewLua::CallbackWindowSlotChanged(int a_FnRef, cWindow & a_Window, int a_SlotNum)
+{
+ ASSERT(a_FnRef != LUA_REFNIL);
+
+ 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_pushnumber (m_LuaState, a_SlotNum);
+
+ // Call function:
+ int s = lua_pcall(m_LuaState, 2, 0, 0);
+ if (report_errors(m_LuaState, s))
+ {
+ LOGERROR("LUA error in %s. Stack size: %i", __FUNCTION__, lua_gettop(m_LuaState));
+ }
+}
+
+
+
+
+
// Helper functions
bool cPlugin_NewLua::PushFunction(const char * a_FunctionName, bool a_bLogError /* = true */)
{