Jump to content

Need help understanding Recipe.OnCreate.UpgradeSpear


Recommended Posts

My question is about the "items" parameter: is it all the items in the player's inventory or just the Crafted Spear or Hand Weapon that the player selected?


I left the code snippet below for your convenience.


-- get a mix of spear & upgrade item to do a correct condition of the result
-- we take the craftedSpear condition and substract the attached weapon condition
function Recipe.OnCreate.UpgradeSpear(items, result, player, selectedItem)
    local conditionMax = 0;
    for i=0,items:size() - 1 do
        if items:get(i):getType() == "SpearCrafted" then
            conditionMax = items:get(i):getCondition()
    for i=0,items:size() - 1 do
        if instanceof (items:get(i), "HandWeapon") and items:get(i):getType() ~= "SpearCrafted" then
            conditionMax = conditionMax - ((items:get(i):getConditionMax() - items:get(i):getCondition())/2)
    if conditionMax > result:getConditionMax() then
        conditionMax = result:getConditionMax();
    if conditionMax < 2 then
        conditionMax = 2;



Edited by Undefined
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...