Jump to content

How can i make football helmet sewable


Recommended Posts

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

@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 by Seiai
Link to comment
Share on other sites

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

@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 by craxue
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
 Share

×
  • Create New...