summaryrefslogtreecommitdiffstats
path: root/source/cPlugin_NewLua.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-12 23:30:32 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-12 23:30:32 +0200
commit223967b80d783df1be2df5f74ddf198f373fbc57 (patch)
tree6bf155fc8cfbdf635b6ef40d4e7ab200029de6d9 /source/cPlugin_NewLua.cpp
parentUpdated the crafting recipes architecture to better support crafting hooks. Removed the old recipe file and implementation altogether. (diff)
downloadcuberite-223967b80d783df1be2df5f74ddf198f373fbc57.tar
cuberite-223967b80d783df1be2df5f74ddf198f373fbc57.tar.gz
cuberite-223967b80d783df1be2df5f74ddf198f373fbc57.tar.bz2
cuberite-223967b80d783df1be2df5f74ddf198f373fbc57.tar.lz
cuberite-223967b80d783df1be2df5f74ddf198f373fbc57.tar.xz
cuberite-223967b80d783df1be2df5f74ddf198f373fbc57.tar.zst
cuberite-223967b80d783df1be2df5f74ddf198f373fbc57.zip
Diffstat (limited to 'source/cPlugin_NewLua.cpp')
-rw-r--r--source/cPlugin_NewLua.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp
index fc07b266e..8efca5338 100644
--- a/source/cPlugin_NewLua.cpp
+++ b/source/cPlugin_NewLua.cpp
@@ -384,6 +384,75 @@ bool cPlugin_NewLua::OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk *
+bool cPlugin_NewLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
+{
+ cCSLock Lock(m_CriticalSection);
+ if (!PushFunction("OnPreCrafting"))
+ return false;
+
+ tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
+ tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
+ tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
+
+ if (!CallFunction(3, 1, "OnPreCrafting"))
+ {
+ return false;
+ }
+
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ return bRetVal;
+}
+
+
+
+
+
+bool cPlugin_NewLua::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
+{
+ cCSLock Lock(m_CriticalSection);
+ if (!PushFunction("OnCraftingNoRecipe"))
+ return false;
+
+ tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
+ tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
+ tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
+
+ if (!CallFunction(3, 1, "OnCraftingNoRecipe"))
+ {
+ return false;
+ }
+
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ return bRetVal;
+}
+
+
+
+
+
+bool cPlugin_NewLua::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
+{
+ cCSLock Lock(m_CriticalSection);
+ if (!PushFunction("OnPostCrafting"))
+ return false;
+
+ tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
+ tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
+ tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
+
+ if (!CallFunction(3, 1, "OnPostCrafting"))
+ {
+ 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 );