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/ManualBindings.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 'source/ManualBindings.cpp')
-rw-r--r-- | source/ManualBindings.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp index ceb24da30..96cd14370 100644 --- a/source/ManualBindings.cpp +++ b/source/ManualBindings.cpp @@ -938,6 +938,41 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S) +static int tolua_cLuaWindow_SetOnClosing(lua_State * tolua_S) +{ + // Function signature: cPlayer:SetOnClosing(CallbackFunction) + + // Retrieve the plugin instance from the Lua state + cPlugin_NewLua * Plugin = GetLuaPlugin(tolua_S); + if (Plugin == NULL) + { + // Warning message has already been printed by GetLuaPlugin(), bail out silently + return 0; + } + + // Get the parameters: + cLuaWindow * self = (cLuaWindow *)tolua_tousertype(tolua_S, 1, NULL); + if (self == NULL) + { + LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self); + return 0; + } + int FnRef = luaL_ref(tolua_S, LUA_REGISTRYINDEX); // Store function reference + if (FnRef == LUA_REFNIL) + { + LOGERROR("%s: Cannot create a function reference. Callback not set.", __FUNCTION__); + return 0; + } + + // Set the callback + self->SetOnClosing(Plugin, FnRef); + return 0; +} + + + + + static int tolua_cPlugin_NewLua_AddWebTab(lua_State * tolua_S) { cPlugin_NewLua * self = (cPlugin_NewLua*)tolua_tousertype(tolua_S,1,0); @@ -1265,6 +1300,10 @@ void ManualBindings::Bind( lua_State* tolua_S ) tolua_function(tolua_S, "OpenWindow", tolua_cPlayer_OpenWindow); tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cLuaWindow"); + tolua_function(tolua_S, "SetOnClosing", tolua_cLuaWindow_SetOnClosing); + tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cPlugin_NewLua"); tolua_function(tolua_S, "AddWebTab", tolua_cPlugin_NewLua_AddWebTab); tolua_function(tolua_S, "AddTab", tolua_cPlugin_NewLua_AddTab); |