craxue Posted June 19, 2015 Share Posted June 19, 2015 I want to repair the helmet by sewing kit.But even i added the tag "addTag("needssewing")" in the function of "footaball" that is in "hats.lua".It still doesn't work. Who can help me make it work ? Link to comment Share on other sites More sharing options...
Seiai Posted June 19, 2015 Share Posted June 19, 2015 (edited) @craxue, thats because clothing and the sewing kit work via the fueled component, so the sewingkit is effectivly "refueling" it. the football helmet on the other hand, works via the armor component. u would probably have to create a new component like armorrepairer.lua for example, add that to sewingkits in a prefabpostinit and give that component a inventoryaction when u use the item on another item, to repair armor, if the targetitem has armor. Edited June 19, 2015 by Seiai Link to comment Share on other sites More sharing options...
DarkXero Posted June 20, 2015 Share Posted June 20, 2015 local ACTIONS = GLOBAL.ACTIONS local old_sew = ACTIONS.SEW.fn ACTIONS.SEW.fn = function(act) if act.target and act.target.components.armor and act.invobject and act.invobject.components.sewing then if act.target:HasTag("sewablearmor") then return act.invobject.components.sewing:DoArmorSewing(act.target, act.doer) end end return old_sew(act) end AddPrefabPostInit("footballhat", function(inst) inst:AddTag("needssewing") inst:AddTag("sewablearmor") end) AddComponentPostInit("sewing", function(self) self.DoArmorSewing = function(self, target, doer) if target.components.armor and target:HasTag("sewablearmor") then local armor = target.components.armor armor:SetPercent(armor:GetPercent() + 0.5) if self.inst.components.finiteuses then self.inst.components.finiteuses:Use(1) end if self.onsewn then self.onsewn(self.inst, target, doer) end return true end end end) Link to comment Share on other sites More sharing options...
craxue Posted June 20, 2015 Author Share Posted June 20, 2015 (edited) @craxue,thats because clothing and the sewing kit work via the fueled component, so the sewingkit is effectivly "refueling" it. the football helmet on the other hand, works via the armor component. u would probably have to create a new component like armorrepairer.lua for example, add that to sewingkits in a prefabpostinit and give that component a inventoryaction when u use the item on another item, to repair armor, if the targetitem has armor.THANK YOU SO MUCH ! local ACTIONS = GLOBAL.ACTIONSlocal old_sew = ACTIONS.SEW.fnACTIONS.SEW.fn = function(act) if act.target and act.target.components.armor and act.invobject and act.invobject.components.sewing then if act.target:HasTag("sewablearmor") then return act.invobject.components.sewing:DoArmorSewing(act.target, act.doer) end end return old_sew(act)endAddPrefabPostInit("footballhat", function(inst) inst:AddTag("needssewing") inst:AddTag("sewablearmor")end)AddComponentPostInit("sewing", function(self) self.DoArmorSewing = function(self, target, doer) if target.components.armor and target:HasTag("sewablearmor") then local armor = target.components.armor armor:SetPercent(armor:GetPercent() + 0.5) if self.inst.components.finiteuses then self.inst.components.finiteuses:Use(1) end if self.onsewn then self.onsewn(self.inst, target, doer) end return true end endend)thank you !!! your help is very useful Edited June 20, 2015 by craxue Link to comment Share on other sites More sharing options...
Maris Posted June 21, 2015 Share Posted June 21, 2015 Great soultion!) 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