Kotoni Posted June 13, 2021 Share Posted June 13, 2021 Hello. I'm dipping my toes into modding and want to make it so that my character can get extra food from a Crock Pot when harvesting the food from it, like this Ram does. However, I have no idea how to do that. Any ideas? Thanks in advance! Link to comment Share on other sites More sharing options...
Monti18 Posted June 14, 2021 Share Posted June 14, 2021 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. 1 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