summaryrefslogtreecommitdiffstats
path: root/source/cPlugin_NewLua.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/cPlugin_NewLua.cpp')
-rw-r--r--source/cPlugin_NewLua.cpp56
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 );