diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-13 19:37:23 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-13 19:37:23 +0200 |
commit | 1c60680fbac2f06823dba123241adc607363a25b (patch) | |
tree | 51149ad6910150fd6ffa51ac9ba8d9c6f8ad88fb /source/cPlugin_NewLua.cpp | |
parent | Modified ToLua additional script to allow multi-usertype virtual functions (diff) | |
download | cuberite-1c60680fbac2f06823dba123241adc607363a25b.tar cuberite-1c60680fbac2f06823dba123241adc607363a25b.tar.gz cuberite-1c60680fbac2f06823dba123241adc607363a25b.tar.bz2 cuberite-1c60680fbac2f06823dba123241adc607363a25b.tar.lz cuberite-1c60680fbac2f06823dba123241adc607363a25b.tar.xz cuberite-1c60680fbac2f06823dba123241adc607363a25b.tar.zst cuberite-1c60680fbac2f06823dba123241adc607363a25b.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cPlugin_NewLua.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp index 8efca5338..ae79ebd3c 100644 --- a/source/cPlugin_NewLua.cpp +++ b/source/cPlugin_NewLua.cpp @@ -5,6 +5,7 @@ #include "cPlugin_NewLua.h"
#include "cMCLogger.h"
#include "cWebPlugin_Lua.h"
+#include "LuaItems.h"
extern "C"
{
@@ -21,14 +22,26 @@ extern "C" #include <dirent.h>
#endif
+
+
+
+
extern bool report_errors(lua_State* lua, int status);
+
+
+
+
cPlugin_NewLua::cPlugin_NewLua( const char* a_PluginName )
: m_LuaState( 0 )
{
m_Directory = a_PluginName;
}
+
+
+
+
cPlugin_NewLua::~cPlugin_NewLua()
{
cCSLock Lock( m_CriticalSection );
@@ -45,6 +58,10 @@ cPlugin_NewLua::~cPlugin_NewLua() }
}
+
+
+
+
bool cPlugin_NewLua::Initialize()
{
cCSLock Lock( m_CriticalSection );
@@ -115,6 +132,10 @@ bool cPlugin_NewLua::Initialize() return bSuccess;
}
+
+
+
+
void cPlugin_NewLua::OnDisable()
{
cCSLock Lock( m_CriticalSection );
@@ -124,6 +145,10 @@ void cPlugin_NewLua::OnDisable() CallFunction(0, 0, "OnDisable");
}
+
+
+
+
void cPlugin_NewLua::Tick(float a_Dt)
{
cCSLock Lock( m_CriticalSection );
@@ -159,7 +184,7 @@ bool cPlugin_NewLua::OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player ) -bool cPlugin_NewLua::OnDisconnect( std::string a_Reason, cPlayer* a_Player )
+bool cPlugin_NewLua::OnDisconnect(const AString & a_Reason, cPlayer* a_Player )
{
cCSLock Lock( m_CriticalSection );
if( !PushFunction("OnDisconnect") )
@@ -453,6 +478,35 @@ bool cPlugin_NewLua::OnPostCrafting(const cPlayer * a_Player, const cCraftingGri +bool cPlugin_NewLua::OnBlockToPickup(
+ BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups
+)
+{
+ cLuaItems Pickups(a_Pickups);
+ cCSLock Lock(m_CriticalSection);
+ if (!PushFunction("OnBlockToPickup"))
+ return false;
+
+ tolua_pushnumber (m_LuaState, a_BlockType);
+ tolua_pushnumber (m_LuaState, a_BlockMeta);
+ tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
+ tolua_pushusertype(m_LuaState, (void *)&a_EquippedItem, "cItem");
+ tolua_pushusertype(m_LuaState, (void *)&Pickups, "cLuaItems");
+
+ if (!CallFunction(5, 1, "OnBlockToPickup"))
+ {
+ return false;
+ }
+
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ return bRetVal;
+}
+
+
+
+
+
cWebPlugin_Lua* cPlugin_NewLua::CreateWebPlugin(lua_State* a_LuaState)
{
cCSLock Lock( m_CriticalSection );
|