Jump to content

Recommended Posts

All I'm doing is making an item that is identical to the portable crockpot Warly has, however, even by just copying the prefab and changing the proper names for anim files etc, I get stead crashes saying the issue are on the stewer component or parts.

 I have no idea what exactly the issue is at, I would be super glad if I got a pointer on what might be going on.
 In case, here is the prefab and the error log.

ord_microwave.lua

client_log.txt

"cripts/components/stewer.lua:141 in (method) StartCooking (Lua) <125-171>
   self =
      oncontinuecooking = function - ../mods/ordinary rick/scripts/prefabs/ord_microwave.lua:140
      oncontinuedone = function - ../mods/ordinary rick/scripts/prefabs/ord_microwave.lua:133
      ondonecooking = function - ../mods/ordinary rick/scripts/prefabs/ord_microwave.lua:122
      onharvest = function - ../mods/ordinary rick/scripts/prefabs/ord_microwave.lua:149
      onstartcooking = function - ../mods/ordinary rick/scripts/prefabs/ord_microwave.lua:61
      onspoil = function - ../mods/ordinary rick/scripts/prefabs/ord_microwave.lua:108
      inst = 100327 - ord_microwave (valid:true)
      spoiledproduct = spoiled_food
      cooktimemult = 1"

Thank you for your time!

That's because of what happens on line 140 in stewer.lua.

Line 140: self.product, cooktime = cooking.CalculateRecipe(self.inst.prefab, ings)
Line 141: local productperishtime = cooking.GetRecipe(self.inst.prefab, self.product).perishtime or 0

It complains about something being nil on line 141 and since we know that self.inst.prefab is not likely to be nil, and it says ".perishtime or 0", we can deduce that it is self.product which is nil.

The reason why self.product is nil, is because cooking.CalculateRecipe takes the prefab name of the cooker, which is your custom prefab's name instead of the name of any of the existing stewer prefabs ("cookpot", "portablecookpot" or "portablespicer"). When cooking.CalculateRecipe tries to use its GetCandidateRecipes function. it finds no candidate recipes for your custom prefab.

I think the best thing would be to completely overwrite the StartCooking function in the stewer component specifically on your prefab only, copy the entire code from the original function, but instead of

self.product, cooktime = cooking.CalculateRecipe(self.inst.prefab, ings)
local productperishtime = cooking.GetRecipe(self.inst.prefab, self.product).perishtime or 0

you do

self.product, cooktime = cooking.CalculateRecipe("SPECIFIC_EXISTING_STEWER_PREFAB_NAME", ings)
local productperishtime = cooking.GetRecipe("SPECIFIC_EXISTING_STEWER_PREFAB_NAME", self.product).perishtime or 0

Replace SPECIFIC_EXISTING_STEWER_PREFAB_NAME with the prefab name of the existing stewer ("cookpot", "portablecookpot" or "portablespicer") whose recipes you want it to be able to cook.

I think the rest of the functions will work fine, since they operate on self.product, so as long as that is set correctly in StartCooking, it should be fine.

Edited by Ultroman

You can override anything of a component in a prefab file. A component is just a prebuilt chunk of code that is standardized for everything that wants to use it. You can ofc extend functions no differently than you modify variables of a component.

 

Did you make sure to add the cookpotfoods recipes to your custom cookpot?

  • Like 1
1 hour ago, IronHunter said:

You can override anything of a component in a prefab file. A component is just a prebuilt chunk of code that is standardized for everything that wants to use it. You can ofc extend functions no differently than you modify variables of a component.

Well heckity I didn't know that at all. I just tried it but it led me to crash with the game telling me the issue went to 'cooking', I might be overriding it wrong.

As for 'cookpotfoods' no, didn't even consider that. Well actually, I would need more insight on that. It's first time making a custom crockpot so I am, almost entirely blind on it.

OH heck sorry my bad I forgot to put it here! I forgot and thought I had attached it too, heck.

ord_microwave.lua

I'm almost certain I didn't place it properly, I never overwrote a component like this, sorry for the big mess.

Edited by halfrose
14 hours ago, halfrose said:

As for 'cookpotfoods' no, didn't even consider that. Well actually, I would need more insight on that. It's first time making a custom crockpot so I am, almost entirely blind on it.

for k,recipe in pairs (require("preparedfoods")) do AddCookerRecipe("yourcookpotname", recipe) end

I would run this in your modmain, if you want to add warly's food too you need to make a second copy of this code with preparedfoods replaced with preparedfoods_warly.

  • Like 1
6 hours ago, IronHunter said:

for k,recipe in pairs (require("preparedfoods")) do AddCookerRecipe("yourcookpotname", recipe) end

I would run this in your modmain, if you want to add warly's food too you need to make a second copy of this code with preparedfoods replaced with preparedfoods_warly.

That actually did it! it works now after adding that!

Thank you both for helping me out, I would have most likely been stuck in this for the longest time if you two didn't come here and helped me through my inexperience!

Thank you a lot, you guys are the best!
 

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