Added working crafting hooks HOOK_PRE_CRAFTING, HOOK_CRAFTING_NO_RECIPE and HOOK_POST_CRAFTING
git-svn-id: http://mc-server.googlecode.com/svn/trunk@598 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user