Obligatory "I ruined everything!" thread
#4
Rev 598, big change Smile

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
Reply
Thanks given by: Taugeshtu


Messages In This Thread
RE: Obligatory "I ruined everything!" thread - by xoft - 06-13-2012, 07:37 AM



Users browsing this thread: 5 Guest(s)