diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-18 11:56:28 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-18 11:56:28 +0200 |
commit | 2691e8daed826e944ca38f4787c77273edbf9404 (patch) | |
tree | 3f9fca349df2253c2c314abf2e0c22e8af7f9604 /source/cPlugin_NewLua.cpp | |
parent | Added Core files to the VC2008 project (so that they can be opened from the IDE there, nothing more) (diff) | |
download | cuberite-2691e8daed826e944ca38f4787c77273edbf9404.tar cuberite-2691e8daed826e944ca38f4787c77273edbf9404.tar.gz cuberite-2691e8daed826e944ca38f4787c77273edbf9404.tar.bz2 cuberite-2691e8daed826e944ca38f4787c77273edbf9404.tar.lz cuberite-2691e8daed826e944ca38f4787c77273edbf9404.tar.xz cuberite-2691e8daed826e944ca38f4787c77273edbf9404.tar.zst cuberite-2691e8daed826e944ca38f4787c77273edbf9404.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cPlugin_NewLua.cpp | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp index 7f7f0c20c..51d2dc9df 100644 --- a/source/cPlugin_NewLua.cpp +++ b/source/cPlugin_NewLua.cpp @@ -204,41 +204,56 @@ bool cPlugin_NewLua::OnDisconnect(const AString & a_Reason, cPlayer* a_Player ) -bool cPlugin_NewLua::OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player ) +bool cPlugin_NewLua::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) { - cCSLock Lock( m_CriticalSection ); - if( !PushFunction("OnBlockPlace") ) + cCSLock Lock(m_CriticalSection); + if (!PushFunction("OnBlockPlace")) + { return false; + } - tolua_pushusertype(m_LuaState, a_PacketData, "cPacket_BlockPlace"); tolua_pushusertype(m_LuaState, a_Player, "cPlayer"); + tolua_pushnumber (m_LuaState, a_BlockX); + tolua_pushnumber (m_LuaState, a_BlockY); + tolua_pushnumber (m_LuaState, a_BlockZ); + tolua_pushnumber (m_LuaState, a_BlockFace); + tolua_pushusertype(m_LuaState, (void *)&a_HeldItem, "cItem"); - if( !CallFunction(2, 1, "OnBlockPlace") ) + if (!CallFunction(6, 1, "OnBlockPlace")) + { return false; + } - bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0); - return bRetVal; + return (tolua_toboolean( m_LuaState, -1, 0) > 0); } -bool cPlugin_NewLua::OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) +bool cPlugin_NewLua::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) { - cCSLock Lock( m_CriticalSection ); - if( !PushFunction("OnBlockDig") ) + cCSLock Lock(m_CriticalSection); + if (!PushFunction("OnBlockDig")) + { return false; + } - tolua_pushusertype(m_LuaState, a_PacketData, "cPacket_BlockDig"); tolua_pushusertype(m_LuaState, a_Player, "cPlayer"); - tolua_pushusertype(m_LuaState, a_PickupItem, "cItem"); + tolua_pushnumber (m_LuaState, a_BlockX); + tolua_pushnumber (m_LuaState, a_BlockY); + tolua_pushnumber (m_LuaState, a_BlockZ); + tolua_pushnumber (m_LuaState, a_BlockFace); + tolua_pushnumber (m_LuaState, a_Status); + tolua_pushnumber (m_LuaState, a_OldBlock); + tolua_pushnumber (m_LuaState, a_OldMeta); - if( !CallFunction(3, 1, "OnBlockDig") ) + if (!CallFunction(8, 1, "OnBlockDig")) + { return false; + } - bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0); - return bRetVal; + return (tolua_toboolean( m_LuaState, -1, 0) > 0); } @@ -265,15 +280,17 @@ bool cPlugin_NewLua::OnChat( const char* a_Chat, cPlayer* a_Player ) -bool cPlugin_NewLua::OnLogin( cPacket_Login* a_PacketData ) +bool cPlugin_NewLua::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) { cCSLock Lock( m_CriticalSection ); if( !PushFunction("OnLogin") ) return false; - tolua_pushusertype(m_LuaState, a_PacketData, "cPacket_Login"); + tolua_pushusertype (m_LuaState, a_Client, "cClientHandle"); + tolua_pushnumber (m_LuaState, a_ProtocolVersion); + tolua_pushcppstring(m_LuaState, a_Username); - if( !CallFunction(1, 1, "OnLogin") ) + if (!CallFunction(3, 1, "OnLogin")) return false; bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0); |