Zhilo Posted December 22, 2020 Share Posted December 22, 2020 (edited) Ok, this one has been rather complicated and i havent found other mods that do a similar thing. I want my modded character to be such a terrible cook, that no matter what she puts in the crockpot, there's a 1 in 10 chance it will produce a monster lasagna instead of the intended food item. Any help figuring this out, or if you know of a mod that does something similar i could learn from, it would be much appreciated. Edited December 22, 2020 by Zhilo Link to comment Share on other sites More sharing options...
DecDuck Posted December 23, 2020 Share Posted December 23, 2020 Possibly add something in the stewer component or replace the stewer component on crockpots to check if your character is using it and then change the output? stewer.lua, 71: local function dostew(inst, self) self.task = nil self.targettime = nil self.spoiltime = nil if self.ondonecooking ~= nil then self.ondonecooking(inst) end if self.product == self.spoiledproduct then if self.onspoil ~= nil then self.onspoil(inst) end elseif self.product ~= nil then local prep_perishtime = cooking.GetRecipe(inst.prefab, self.product).perishtime or 0 if prep_perishtime > 0 then local prod_spoil = self.product_spoilage or 1 self.spoiltime = prep_perishtime * prod_spoil self.targettime = GetTime() + self.spoiltime self.task = self.inst:DoTaskInTime(self.spoiltime, dospoil, self) end end self.done = true end Somehow override that to edit the output based on a random number Link to comment Share on other sites More sharing options...
Zhilo Posted December 23, 2020 Author Share Posted December 23, 2020 well i tried a couple things with no success. First I attempted to add a 10% chance for it to produce somethign different where i tought was pewell i tried a couple things with no success. First I attempted to add a 10% chance for it to produce somethign different where i tought was pertinent local function dostew(inst, self) self.task = nil self.targettime = nil self.spoiltime = nil if self.ondonecooking ~= nil then self.ondonecooking(inst) end if self.product == self.spoiledproduct then if self.onspoil ~= nil then self.onspoil(inst) end elseif self.product ~= nil then local lasagnachance = math.random(1,10) if lasagnachance == 1 then local recipe = cooking.GetRecipe(inst.prefab, self.product) else local recipe = cooking.GetRecipe(inst.prefab, monsterlasagna) end local prep_perishtime = (recipe ~= nil and (recipe.cookpot_perishtime or recipe.perishtime)) or 0 if prep_perishtime > 0 then local prod_spoil = self.product_spoilage or 1 self.spoiltime = prep_perishtime * prod_spoil self.targettime = GetTime() + self.spoiltime self.task = self.inst:DoTaskInTime(self.spoiltime, dospoil, self) end end But testing making about 20 meatballs i saw no change happen, or even a crash orf some sort, just nothing. Then I tried to look elsewere in the code, and saw the line local prod = SpawnPrefab(self.product) and i thought "well maybe here is where the food item actually spawns on top of the crockpot when cooking ends, maybe cause a replacement here?" and thus i tried: function Stewer:StopCooking(reason) if self.task ~= nil then self.task:Cancel() self.task = nil end if self.product ~= nil and reason == "fire" then local lasagnachance = math.random(1,10) if lasagnachance == 1 then local prod = SpawnPrefab("monsterlasagna") else local prod = SpawnPrefab(self.product) end if prod ~= nil then prod.Transform:SetPosition(self.inst.Transform:GetWorldPosition()) prod:DoTaskInTime(0, StopProductPhysics) end end self.product = nil self.product_spoilage = nil self.spoiltime = nil self.targettime = nil self.done = nil end and again absolutely nothing changes. Perhaps I am not even properly telling the code to use the monster lasagna food item. 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