[Bug] Issue with crafting and Food_Decay service

Hello there!

I’m trying to finish a mod however I encountered an issue on something that I fooled myself thinking it would be easier… I’m no coder/expert but I’ve been trying to learn and for that reason I came up with a service that would be needed for this new mod.

The service is basically the same as the Food_Decay service, which I shamelessly copied and edited to learn - however it has a little twist: if the item is inside a container, it decays to a different version. I actually managed to, by trial and error + reading the food_decay service over and over, create the service I wanted. And it seemed to work as intended! Hooray!..

…there is, however, one problem which seems to be a “bug” from the food_decay service itself that I can’t seem to fix, I’ve tested it without my mod (just the default food_decay service) and it happens… And turns out that bug is very complicated for my mod. :stuck_out_tongue:

The bug seems to be… apparently the listeners (which as far as I understood are what “check” for the rotting food and decide to take action (or not)) doesn’t work or are not created if the item never “touches” the ground - that is, if they go straight to a container.

I’ll give an example: imagine an Output Box for berries and a Berry Basket recipe. If you craft a Berry Basket and the crafter drops it on the ground, the berry basket will rot after a while, even if put inside a crate. However, if your crafter finishes crafting and goes straight to the output box (as they usually do with output boxes), the item will never rot. (that’s how I tested it, by creating a Berry Basket recipe for the carpenter ^_^)

Steps to reproduce Without any sort of modding, I guess that you could reproduce it by making a cook create food and put it straight into an output box and then isolate that output box so the food is not eaten or moved away. It will then never rot.

Expected Results Food would rot after a while, as it happens to most food.

Actual Results If the “Food item” never “touches the ground” after crafted and goes straight to a container it never rots;

Versions and Mods:
Default game, unstable branch (24.10) + a mod that added a berry basket recipe to the carpenter that I created for testing.

As stated above, I found this bug working on a mod. Although in the case of the food_decay system it is a very specific and probably irrelevant issue (since food will certainly, in most cases, be moved/eaten or taken from any output boxes anyway) it is somewhat hindering for my mod though, because my system (based on Food_Decay) is actually a cooling system where the crafted item is too hot and you must wait for it to “cool down” before use. The issue was found when the items never cooled down on the output shelf.

Now, I know that I shouldn’t expect a bug fix just to sort out my own modding issues (shame on me! :stuck_out_tongue: ) but I wanted to report it nonetheless; On the other hand, if someone that is more proficient with LUA scripting would like to give me a hand on devising at least a temporary fix, I’d be very grateful! Please PM me if you are that person :slight_smile:

I would suggest using the evolve (or the similar grow) component, but it is also based on being placed.
If you need a simple timer that change the item into another, maybe your best bet is creating your own component.

1 Like

Indeed, my first guess was the crop growing system but then I found out it doesn’t fit my needs… I looked around on the other systems and the food decay is the only one that I felt could be of use to me.

Here’s an overview of what my system requires:

  • Items must change to another entity after a while;
  • Items are affected anywhere (inside containers, inventories, on the world)
  • The entity they change to must be different if they’re in a container or dropped on the ground/stockpiles

It’s pretty much the same as Food_Decay with the addition of the “different” entity thing, which I did manage to come up with myself since the Food_Decay service has a check (IF… in storage…) and it wasn’t that hard to figure out how to edit it, so I almost managed to create the system I wanted.

The only problem is that bug from the Food_Decay system itself, where items do not decay if placed in a container right after being crafted (without ever “existing” in the world itself)

As for creating my own component, maybe it could indeed be simpler/cleaner, possibly… But I’m afraid I don’t have the skill to create one from scratch yet :frowning: I could try, but creating a new service based on Food_Decay seemed easier for that purpose