Sign in to follow this  
_Q_

Custom food inivisible on crock pot

Recommended Posts

_Q_    644

I want to port some mod from single player to DST but food is invisible on crock pot in DST for some reason.

Any idea why this is happening? I have all network and other stuff required in DST added.

Share this post


Link to post
Share on other sites
rezecib    3183

@_Q_, The "cook_pot_foods" bank is hardcoded in cookpot.lua's donecookfn:

local function donecookfn(inst)	if not inst:HasTag("burnt") then		inst.AnimState:PlayAnimation("cooking_pst")		inst.AnimState:PushAnimation("idle_full")		inst.AnimState:OverrideSymbol("swap_cooked", "cook_pot_food", inst.components.stewer.product)				inst.SoundEmitter:KillSound("snd")		inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")		inst.Light:Enable(false)		--play a one-off sound	endend

I had a (private) conversation with outseeker a couple of months ago about this, so I'll copy some of that here:

 

Something like this in the modmain:

local mynewproducts = {mynewproduct_1 = true, mynewproduct_2 = true}if GLOBAL.TheNet:GetIsServer() then    AddPrefabPostInit("cookpot", function(inst)        local old_ondonecooking  = inst.components.stewer.ondonecooking        inst.components.stewer.ondonecooking = function(inst)            local ret = old_ondonecooking(inst)            local product = inst.components.stewer.product            if mynewproducts[product] then                inst.AnimState:OverrideSymbol("swap_cooked", product, product)            else                return ret            end        end    end)end

A similar patch it needed for the oncontinuedone function, otherwise the products are invisible if you join after they are cooked.

Share this post


Link to post
Share on other sites
_Q_    644

@_Q_, The "cook_pot_foods" bank is hardcoded in cookpot.lua's donecookfn:

local function donecookfn(inst)	if not inst:HasTag("burnt") then		inst.AnimState:PlayAnimation("cooking_pst")		inst.AnimState:PushAnimation("idle_full")		inst.AnimState:OverrideSymbol("swap_cooked", "cook_pot_food", inst.components.stewer.product)				inst.SoundEmitter:KillSound("snd")		inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")		inst.Light:Enable(false)		--play a one-off sound	endend

I had a (private) conversation with outseeker a couple of months ago about this, so I'll copy some of that here:

 

Something like this in the modmain:

local mynewproducts = {mynewproduct_1 = true, mynewproduct_2 = true}if GLOBAL.TheNet:GetIsServer() then    AddPrefabPostInit("cookpot", function(inst)        local old_ondonecooking  = inst.components.stewer.ondonecooking        inst.components.stewer.ondonecooking = function(inst)            local ret = old_ondonecooking(inst)            local product = inst.components.stewer.product            if mynewproducts[product] then                inst.AnimState:OverrideSymbol("swap_cooked", product, product)            else                return ret            end        end    end)end

A similar patch it needed for the oncontinuedone function, otherwise the products are invisible if you join after they are cooked.

 

So they changed this, it is possible to add custom foods without any other scripts in DS.

Thanks.

 

Share this post


Link to post
Share on other sites
rezecib    3183

@_Q_, Yeah, in single-player it checks if it's a mod product:

local function ShowProduct(inst)	if not inst:HasTag("burnt") then		local product = inst.components.stewer.product	    if IsModCookingProduct(inst.prefab, product) then	        inst.AnimState:OverrideSymbol("swap_cooked", product, product)	    else			inst.AnimState:OverrideSymbol("swap_cooked", "cook_pot_food", product)		end	endend

I'm sure that will get added back at some point. @PeterA?

Share this post


Link to post
Share on other sites
UnderwearApp    173

Any progress on this? I still have a modded food item that is invisible while another shows up in the wrong position as shown here:

 

http://images.akamai.steamusercontent.com/ugc/534017438311755444/4A2D2F01195E912CCD1F8E2E0511954C8B3D1591/

 

I tried comparing the code and see no glaring differences. Anyone have any suggestions?

 

Thanks in advance.

Share this post


Link to post
Share on other sites
PeterA    8544

Thanks for pointing this out! Unfortunately I missed the forum notification about this thread, but I've added it to the list of things to fix now.

 

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites
UnderwearApp    173

Thanks for pointing this out! Unfortunately I missed the forum notification about this thread, but I've added it to the list of things to fix now.

Thanks!

Sounds good Peter. Thanks for the update. Edited by ProfFarnsworth

Share this post


Link to post
Share on other sites
PeterA    8544

I've brought back this code and tested it out with the Tungsten Mod/(Gentlemen's Mod) and was able to remove the crockpot fix that reze recommended. You'll get the lua code change in the next update.

 

Thanks for all the information everyone! @ProfFarnsworth@rezecib, and @_Q_!

  • Like 2

Share this post


Link to post
Share on other sites
UnderwearApp    173

I've brought back this code and tested it out with the Tungsten Mod/(Gentlemen's Mod) and was able to remove the crockpot fix that reze recommended. You'll get the lua code change in the next update.

 

Thanks for all the information everyone! @ProfFarnsworth@rezecib, and @_Q_!

 

Good news everyone!

Share this post


Link to post
Share on other sites
_Q_    644

If this update has not been pushed yet, please ignore. If so, I still have the same issues as above. Just to keep you guys posted.

 

It is, I have made the crock pot food in beefalo and cheese mod and it is visible.

Check your anim files maybe.

 

Wrong position is caused by setting pivot point of the image at the top or bottom corner, pivot must be in the middle of the image.

Also for invisible thing the whole food project must be done in right way.

That is described in the old DS crock pot for modders I think.

http://forums.kleientertainment.com/topic/32910-tutorial-adding-recipes-to-the-crockpot/

Edited by _Q_
  • Like 2

Share this post


Link to post
Share on other sites
_Q_    644
PeterA

I just noticed that custom food doesn't start to rot after is cooked and left on crock pot.

Maybe its a bug or maybe I'm missing something in my custom food prefabs.

Share this post


Link to post
Share on other sites
PeterA    8544

@_Q_, we're not aware of anything in the code that could be causing that behaviour. Have you tried doing a LongUpdate for a really long time and seeing what occurs then? You could also try taking a look at spoiltime in the crockpot's stewer component. That will give you an idea of how long it should take to spoil.

Share this post


Link to post
Share on other sites
_Q_    644

@_Q_, we're not aware of anything in the code that could be causing that behaviour. Have you tried doing a LongUpdate for a really long time and seeing what occurs then? You could also try taking a look at spoiltime in the crockpot's stewer component. That will give you an idea of how long it should take to spoil.

 

I changed the custom food spoil time form 8 days to 40 seconds, maybe that's why it didn't rot, will try again now with some reasonable time set for it.

 

It is spoiling, but the spoiling rate is like 10 times slower, I made 2 of the same food (TUNING.PERISH_ONE_DAY) the one in my inventory turned to rot the one that i left on crock pot was bearly spoiled, like 2 millimeters of spoilage after harvesting it.

 

Edited by _Q_

Share this post


Link to post
Share on other sites
_Q_    644

Hey @_Q_, I wasn't able to reproduce your issue. Mod added crock pot recipes are spoiling at the same rate for me.

 

I tested it out with the mushy_eggs and nopalito recipes in this mod http://steamcommunity.com/sharedfiles/filedetails/?id=381565292

I will do some more testing.

The rate of spoilage on crock pot is like just normal spoilage rate?

I need to take a look at the components and other things that could affect this.

So here is what I got from my testing:

I cooked 3 Fresh Milk at the start of day 1, I put one in the chest, keep one in my inventory. The fresh milk spoil time is set to TUNING.PERISH_ONE_DAY, Fresh Milk turns into Cheese after the perish time runs out.

 

So day 1:

2gtrjmf.jpg

 

v6kq5y.jpg

 

Day 2 (The Fresh Milk in chest and inventory turned to Cheese, the one on crock pot still is good):

2qv9qoz.jpg

 

Day 3 (the one on crock pot is still good, and harvested it - spoilage rate on the second pic)

3508j8j.jpg

 

28ilt00.jpg

 

 

Maybe I got it wrong with the whole spoilage on crock pot and it is working as intended, but seems like it is preserving food, the spoilage rate is much slower than the spoilage rate in chest or inventory.

If its working as intended then sorry for the troubles of testing.

 

Edited by _Q_

Share this post


Link to post
Share on other sites
PeterA    8544
The rate of spoilage on crock pot is like just normal spoilage rate?

 Yeah, it is. It takes place around lines 85 in stewer.lua.

 

If the food you're putting into the crock pot has bogus perishable values, that would affect the length of time it takes to rot in the pot.

 

edit: I did notice a slight difference in spoiling time between two of the items I stewed, but it was marginal and likely attributed to varying input spoilage and varying start stew times.

Share this post


Link to post
Share on other sites
_Q_    644

 Yeah, it is. It takes place around lines 85 in stewer.lua.

 

If the food you're putting into the crock pot has bogus perishable values, that would affect the length of time it takes to rot in the pot.

 

edit: I did notice a slight difference in spoiling time between two of the items I stewed, but it was marginal and likely attributed to varying input spoilage and varying start stew times.

 

I can confirm that TUNING.PERISH_ONE_DAY values for crock pot are wrong, again I made Fresh Milk on day 4 put one in the ice box, other in the inventory, the last one was left on crock pot its end of day 8 and it still sits on the crock pot.

I'm not insane after all. I will continue my tests with other perish values at some other time. 

Perish one day may be set to behave like this to prevent rot crock pot bug or for some other reasons.

Again thanks for your time, and sorry for troubles.

 

Share this post


Link to post
Share on other sites
PeterA    8544
I'm not insane after all. I will continue my tests with other perish values at some other time. 

 

Nope not insane, I was able to reproduce the issue here now too :) I'm investigating further. 

Share this post


Link to post
Share on other sites
PeterA    8544

@_Q_,

  

I actually wasn't able to reproduce the issue. When I thought I had, I was actually seeing the result of a typo in my test code. What I think you're probably seeing though is the difference between the recipe's perish time and the prefab's perish time. Make sure that both the recipe and the prefab's times match.

local cookedmilk =	{		name = "cookedmilk",		test = function(cooker, names, tags) return names.rawmilk and tags.rawmilk > 3 end,		priority = 1,		weight = 1,		foodtype="GENERIC",		health = TUNING.HEALING_MEDSMALL,		hunger = TUNING.CALORIES_MEDSMALL,		sanity = TUNING.SANITY_SMALL,		perishtime = TUNING.PERISH_ONE_DAY,		cooktime = 0.75,	}AddCookerRecipe("cookpot",cookedmilk)
and

--in the cookedmilk's prefab init function	inst:AddComponent("perishable")	inst.components.perishable:SetPerishTime(TUNING.PERISH_ONE_DAY)
If you had a typo (like I did in the recipe's perishtime), then the stewer code falls back and uses TUNING.PERISH_SUPERFAST instead. Which is how I was seeing my discrepancy.

Share this post


Link to post
Share on other sites
UnderwearApp    173

It is, I have made the crock pot food in beefalo and cheese mod and it is visible.

Check your anim files maybe.

 

Wrong position is caused by setting pivot point of the image at the top or bottom corner, pivot must be in the middle of the image.

Also for invisible thing the whole food project must be done in right way.

That is described in the old DS crock pot for modders I think.

http://forums.kleientertainment.com/topic/32910-tutorial-adding-recipes-to-the-crockpot/

 

Thanks for the feedback. I still have the old "crockpot fix" made by squeek I believe. Do we still need these files?

 

I will look at my build and see if I can correct the pivot.

Share this post


Link to post
Share on other sites
_Q_    644

Thanks for the feedback. I still have the old "crockpot fix" made by squeek I believe. Do we still need these files?

 

I will look at my build and see if I can correct the pivot.

 

You don't need crocopotfix.lua script, its part of the mod api now.

 

  • Like 2

Share this post


Link to post
Share on other sites

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
Sign in to follow this