halfrose Posted August 16, 2019 Share Posted August 16, 2019 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.luaclient_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! Link to comment Share on other sites More sharing options...
Ultroman Posted August 16, 2019 Share Posted August 16, 2019 (edited) 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 August 16, 2019 by Ultroman Link to comment Share on other sites More sharing options...
halfrose Posted August 16, 2019 Author Share Posted August 16, 2019 Wait is it actually possible to call a component into a prefab? the only way I've ever used for overwritting component is 'AddComponentPostInit' for the modmain. Link to comment Share on other sites More sharing options...
IronHunter Posted August 17, 2019 Share Posted August 17, 2019 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? 1 Link to comment Share on other sites More sharing options...
halfrose Posted August 17, 2019 Author Share Posted August 17, 2019 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. Link to comment Share on other sites More sharing options...
Ultroman Posted August 17, 2019 Share Posted August 17, 2019 If you want help, post the crash log. Otherwise we don't have a chance. And also your code as it was when the crash happened. Link to comment Share on other sites More sharing options...
halfrose Posted August 17, 2019 Author Share Posted August 17, 2019 after waking up and trying some other things, this gave me a different crash.client_log.txt Link to comment Share on other sites More sharing options...
Ultroman Posted August 17, 2019 Share Posted August 17, 2019 Once again, we can't help without seeing the code that produces the error. Link to comment Share on other sites More sharing options...
halfrose Posted August 17, 2019 Author Share Posted August 17, 2019 (edited) 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 August 17, 2019 by halfrose Link to comment Share on other sites More sharing options...
IronHunter Posted August 17, 2019 Share Posted August 17, 2019 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. 1 Link to comment Share on other sites More sharing options...
halfrose Posted August 17, 2019 Author Share Posted August 17, 2019 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! 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