Undefined Posted September 12, 2022 Share Posted September 12, 2022 (edited) 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() end end 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) end end if conditionMax > result:getConditionMax() then conditionMax = result:getConditionMax(); end if conditionMax < 2 then conditionMax = 2; end result:setCondition(conditionMax); end Edited September 12, 2022 by Undefined Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted September 12, 2022 Share Posted September 12, 2022 IIRC, it's just the ingredients of the recipe, so that would be the spear, weapon and duct tape. You can confirm this by adding a print call within either of the for loops, e.g. print( items:get(i):getType() ) Undefined 1 Link to comment Share on other sites More sharing options...
Undefined Posted September 15, 2022 Author Share Posted September 15, 2022 Thanks man, it was just the 3 items. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now