06-13-2012, 07:37 AM
Rev 598, big change
Added hook names with HOOK prefix (but kept the E_PLUGIN_ -prefixed names for compatibility)
Added three hooks: HOOK_PRE_CRAFTING, HOOK_CRAFTING_NO_RECIPE and HOOK_POST_CRAFTING
Added two new objects: cCraftingGrid and cCraftingRecipe
Crafting is now fully customizable in plugins, example code:
Added hook names with HOOK prefix (but kept the E_PLUGIN_ -prefixed names for compatibility)
Added three hooks: HOOK_PRE_CRAFTING, HOOK_CRAFTING_NO_RECIPE and HOOK_POST_CRAFTING
Added two new objects: cCraftingGrid and cCraftingRecipe
Crafting is now fully customizable in plugins, example code:
Code:
function Initialize( Plugin )
...
PluginManager = cRoot:Get():GetPluginManager()
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PRE_CRAFTING)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_POST_CRAFTING)
end
function OnPreCrafting(Player, Grid, Recipe)
LOG("Test: Pre-crafting for player " .. Player:GetName() .. ".")
return false
end
function OnCraftingNoRecipe(Player, Grid, Recipe)
LOG("Test: Crafting-no-recipe for player " .. Player:GetName() .. ".")
return false
end
function OnPostCrafting(Player, Grid, Recipe)
LOG("Test: Post-crafting for player " .. Player:GetName() .. ".")
local Item = Recipe:GetResult();
-- Mess with the result, have fun:
Recipe:SetResult(Item.m_ItemID + 1, Item.m_ItemCount + 1, Item.m_ItemHealth);
return true
end