Jump to content

Recommended Posts

Yeah I already know mods do this, but I tried it out with my custom fertilizer and normal fertilizer and it doesnt reduce the uses after adding it into the farmplots.

So can someone help me edit this:

AddComponentPostInit("crop", function(self)
    local old = self.Fertilize
    function self:Fertilize(fertilizer)
        local pt = self.inst:GetPosition()
        local ents = GLOBAL.TheSim:FindEntities(pt.x, pt.y, pt.z, 5, {"player", "greenthumb"}, {"playerghost"})
        if #ents > 0 then
            self.growthpercent = self.growthpercent + fertilizer.components.fertilizer.fertilizervalue * self.rate
            self.inst.AnimState:SetPercent("grow", self.growthpercent)
            if self.growthpercent >=1 then
                self.inst.AnimState:PlayAnimation("grow_pst")
                self:Mature()
                self.task:Cancel()
                self.task = nil
            end
            if (fertilizer.components.stackable ~= nil) then
                fertilizer.components.stackable:Get(1):Remove()
            end
            return true
        else
            return old(self, fertilizer)
        end
    end
end)

 

So it consumes the uses each time I use my fertilizers. Thanks!

Derp:

AddComponentPostInit("crop", function(self)
    local old = self.Fertilize
    function self:Fertilize(fertilizer)
        local pt = self.inst:GetPosition()
        local ents = GLOBAL.TheSim:FindEntities(pt.x, pt.y, pt.z, 5, {"player", "greenthumb"}, {"playerghost"})
        if #ents > 0 then
            self.growthpercent = self.growthpercent + fertilizer.components.fertilizer.fertilizervalue * self.rate
            self.inst.AnimState:SetPercent("grow", self.growthpercent)
            if self.growthpercent >=1 then
                self.inst.AnimState:PlayAnimation("grow_pst")
                self:Mature()
                self.task:Cancel()
                self.task = nil
            end
            if (fertilizer.components.stackable ~= nil) then
                fertilizer.components.stackable:Get(1):Remove()
            end
			if (fertilizer.components.finiteuses ~=nil) then
				fertilizer.components.finiteuses:Use(1)
			end
            return true
        else
            return old(self, fertilizer)
        end
    end
end)

It was obvious but im a dumb boi, for anyone else who needs it here you go

Edited by rons0n

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
×
  • Create New...