Jump to content

Recommended Posts

Spoiler

 


AddPrefabPostInit("cookpot", function(inst)
    if inst.components.stewer == nil then
        return
    end
    -- using the same harvest logic and repeat the item giving step once
    local old_harvest = inst.components.stewer.Harvest
    inst.components.stewer.Harvest = function(self, harvester)
        if harvester and harvester.prefab == "ram" then
            if self.done and self.product and harvester.components.inventory then
			
				local loot = nil
				--local loot2 = nil
			
                loot = GLOBAL.SpawnPrefab(self.product)
				--loot2 = GLOBAL.SpawnPrefab(self.product)
				
                if loot ~= nil then
                    if self.spoiltime ~= nil and loot.components.perishable ~= nil then
                        local spoilpercent = self:GetTimeToSpoil() / self.spoiltime
                        loot.components.perishable:SetPercent(self.product_spoilage * spoilpercent)
                        loot.components.perishable:StartPerishing()
                    end
                    harvester.components.inventory:GiveItem(loot, nil, self.inst:GetPosition())
					--[[
					harvester:DoTaskInTime( 1*GLOBAL.FRAMES, function() 
						if harvester and harvester.components.inventory then
							harvester.components.inventory:GiveItem(loot2, nil, self.inst:GetPosition())
						end
					end)]]
					
                end
            end
        end
        return old_harvest(self, harvester)
    end
end)

Extracted of the Ram mod you linked. This code snippet gives the harvester a second time the product, if the harvester is a Ram.

  • Like 1

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...