Undefined Posted September 18, 2022 Share Posted September 18, 2022 (edited) Folder structure (not sure if this is correct): mods/Better Spear Upgrade/media/lua/client/recipecode.lua mod.info file: name=Better Spear Upgrade poster= id=BetterSpearUpgrade description=Changes the formula for the starting condition of an upgraded spear url= Code: local _orig_UpgradeSpear = Recipe.OnCreate.UpgradeSpear -- 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 spearCondition = 0 local spearConditionMax = 0 local weaponCondition = 0 local weaponConditionMax = 0 local conditionMax = 0; for i=0,items:size() - 1 do if items:get(i):getType() == "SpearCrafted" then spearCondition = items:get(i):getCondition() spearConditionMax = items:get(i):getConditionMax() end end for i=0,items:size() - 1 do if instanceof (items:get(i), "HandWeapon") and items:get(i):getType() ~= "SpearCrafted" then weaponCondition = items:get(i):getCondition() weaponConditionMax = items:get(i):getConditionMax() end end local conditionPct = ((spearCondition / spearConditionMax) + (weaponCondition / weaponConditionMax)) / 2 conditionMax = result:getConditionMax() * conditionPct if conditionMax > result:getConditionMax() then conditionMax = result:getConditionMax(); end if conditionMax < 2 then conditionMax = 2; end result:setCondition(conditionMax); end Edited September 18, 2022 by Undefined Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted September 18, 2022 Share Posted September 18, 2022 The vanilla function is in /server/ rather than /client/, so you should probably do likewise. If that doesn't fix it, can you post the stack trace from the console? Undefined 1 Link to comment Share on other sites More sharing options...
Undefined Posted September 20, 2022 Author Share Posted September 20, 2022 (edited) On 9/18/2022 at 7:50 PM, Hugo Qwerty said: The vanilla function is in /server/ rather than /client/, so you should probably do likewise. If that doesn't fix it, can you post the stack trace from the console? Thanks for the response. The TL;DR is that I switched the file to the "server" folder and renamed it to something other than "recipecode.lua" and it worked. --- With the above in mind, before changing the folder name and renaming the file, I checked console.txt and saw errors like "indexing null table UpgradeSpear" and that it also couldn't find other functions that were related to recipecode.lua I figured the mod was replacing the original recipecode.lua and renamed it. I didn't check if changing the folder name had any effect on it, I'll get to that later and post back. Edited September 20, 2022 by Undefined 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