Lumina Posted July 20, 2018 Share Posted July 20, 2018 (edited) Hi, I would like to make a chest that will "repair" item in it. So for example, weapon, armor and tool will regain durability when in it. The creation of a container itself is ok, but i'm not sure how to achieve the "regain durability" part. If someone has ideas or knowledge of how to do this, it would be helpful. Ideally i would like being able to define tier of speed (quick for basic tool, normal for basic armor, slow for advanced weapon and armor) but it would just be a cherry on the cake Edited July 20, 2018 by Lumina Link to comment Share on other sites More sharing options...
Wolf_EX Posted July 24, 2018 Share Posted July 24, 2018 (edited) Was messing around and came up with this to repair items in a container. local armorrepairvalue = .2 --20% local weaponrepairvalue = .1 --10% local toolrepairvalue = .3 --this code goes in function that triggers the repair local items = inst.components.container:FindItems(function(v) return v.components.armor or v.components.weapon or v.components.tool end) for i, v in ipairs(items) do if v.components.armor then v.components.armor:SetPercent(v.components.armor:GetPercent() + armorrepairvalue) elseif v.components.finiteuses then if v.components.weapon then if v.components.finiteuses:GetPercent() < 1 - weaponrepairvalue then v.components.finiteuses:SetPercent(v.components.finiteuses:GetPercent() + weaponrepairvalue) else v.components.finiteuses:SetPercent(1) end elseif v.components.tool then if v.components.finiteuses:GetPercent() < 1 - toolrepairvalue then v.components.finiteuses:SetPercent(v.components.finiteuses:GetPercent() + toolrepairvalue) else v.components.finiteuses:SetPercent(1) end end end end if you want it to slowly repair them over time then you could probably use "DoPeriodicTask" Edited July 24, 2018 by Wolf_EX Link to comment Share on other sites More sharing options...
Lumina Posted July 24, 2018 Author Share Posted July 24, 2018 (edited) Thanks for your help and time ! I will look into this. Edited July 24, 2018 by Lumina 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