What's a Spoiling Plant?


Adds integration between Whats a Spoilage and Spoiling Plant

Tweaks
3 months ago
2.0
61
Manufacturing

g Miscellaneous

4 months ago
(updated 4 months ago)

Out of just pure curiosity because I did raise this thing like yesterday with the whats a spoilage.
Was this an answer to that? Or did you have the same problem?

Edit: Just saw your message, thank you kindly for this

4 months ago

A bit of both. I decided to use Whats a Spoilage, I already knew about the Spoiling Plant and went to check the comments to see if anyone's mentioned mod compatibility. Turns out "someone" had :) I already wanted to functionality, so if anyone else did then it was worth putting in a bit of time to make it happen. It's honestly a very simple mod, so glad you're enjoying it.

Do let me know if anything breaks or if you'd like other functionality.

4 months ago

There is that one problem of some items not being able to trigger their functionality because it is more advanced, like in that demolisher breeding mod if one of hte items spoils, it's meant to spawn baby demolishers, or in "moonshine" (or "fall of promethea") some items are meant to like explode or damage the player a bit (that's how in FoP, they added radiation which kinda doesn't work as it uses the spoilage mechanic.)

So only problems are like:
1-Some mods with unique spoiling products just don't work (The demolisher baby not spawning)
2-In some mods spoiling should be able to be turned on so it does explode or damage the player

But they aren't the biggest of problems so you don't have to fix them right now

4 months ago

Most of that stuff I can't really fix, unfortunately. It would need to be done on a case-by-case basis with each mod, as there's no procedural way to determine what should and shouldn't spoil. The way Whats a Spoilage works is it just walks the entire data.raw.items array, pulls anything with spoilage_ticks and sets that to nil, then generates a reverse recipe from the spoilage_result and sets that to nil, as well. All I did was walk walk data.raw.recipes afterwards and remove any recipe with "wr-spoil-" in the name, since that's what the mod uses as an identifier for its manual spoilage recipes.

I can remove the recipes, but I can't reverse the changes to the items with spoilage removed. That data is gone by the time my mod gets to work, since Whats a Spoilage is an explicit dependency. I could maybe try and duplicate items from an exclusion list at the data stage, replace the write those over the versions that Whats a Spoilage changed, but that's... Kind of a really ugly way of doing it. It also absolutely reams mod compatibility, because any mod which changes these items at the data or data-updates stage will get overwritten at data-final-fixes when I restore those items from backup.

In this case, I think we'll need help from the actual mod-maker. There, it's a fairly trivial change. Add an exclusion list by item prototype name, then check against it when walking data.raw.items and simply skip any items which match anything in that list. A key/value map can do that by just polling for the given key. If you get anything other than nil, that key exists, so skip the item. The mod maker can then just leave the exclusions list in the lua files (like I did for Alchemistry), or expose it via a Mod Settings as a comma-separated text field (like Very Small Chests does). Doing it from an other mod is... a lot more difficult.

4 months ago

Yeah I've seen the code and it seems to be "ctrl + a", as in it removes spoiling for everything with no exception.

And the spoiling plant thing... Sounds like manual work it is, I guess I could message the developers of those mods for them to slightly change how those items spoil into an item which then instantly activates the effects. Just for the spoiling plant to be able to see and make those special resources and activate them but I haven't played with automatic resource triggers, so I can't help but wonder if this would be impossible to make automatically active-atable

4 months ago
(updated 4 months ago)

I may have misunderstood what you meant. Thought we were talking about Whats a Spoilage exclusively. Are you saying that the Spoiling Plant doesn't generate spoiling recipes for some modded items? If so, that would be because Spoiling Plant only generates recipes for items with spoil_result. That's because the "results" field of a recipe can only hold items, fluids and research progress. Spawning critters in the world or causing explosions is done via spoil_to_trigger_result on the item, which isn't a valid thing you can put in a recipe.

So no way to craft Demolisher Babies, meaning that Whats a Spoilage would have to not remove their spoilage. This can't be done from the other mods - has to be done in Whats a Spoilage, during its process of removing spoilage. So we're back to a list of exclusions that the mod will use to skip recipes for the purposes of spoilage removal. If you're going to ask for that, you want to ask on the Whats a Spoilage discussions page. Like I said - it's not complicated to do as a minimum viable product. Just add a local table like:

local exclude = {["demolisher-egg"] = true}

then wrap the contents of the inner loop inside:

if exclude[item.name] then
<stuff>
end

That way, you can just plug the items you want to not be changed in that list and be done with it. But that would still involve digging through the lua files. If I were doing this to my mod, I'd look into adding a string mod option where players can manually enter item prototype names to be excluded, but that's a bit more work.

Long story short - the author of Whats a Spoilage would need to do that. It's not something I can really do after the fact in a compatibility mod like this.

4 months ago

It's not that it doesn't generate, it just that spoiling them doesn't result in anything.
So there is no "spoil_to_trigger_result" on factory building completion? like something similar "craft_to_trigger"? So one could make the spoiling plant work with the mods by ripping out whatever the "spoil_to_trigger_result" does and putting it into the spoiling machines output for specific items?

4 months ago
(updated 4 months ago)

So one could make the spoiling plant work with the mods by ripping out whatever the "spoil_to_trigger_result" does and putting it into the spoiling machines output for specific items?

No. The Spoiling Plant is just a furnace which auto-selects recipes based on ingredient, no different from a large Electric Furnace. The result you get from spoiling items is based on the spoiling recipes that Spoiling Plant auto-generates from spoilable items based on their spoil_result. In other words, the spoiling plant can only produce what a recipe can produce - which is item, fluid, or research progress. Crafting a recipe can't activate a trigger, that's not a valid type for its "results" array.

If you're wanting to hatch Demolisher Eggs inside a building, then that's simply not something that can be done. Well, not without a mess of runtime scripts, which tend to do awful things to UPS. You could probably add a custom container, with a script checking everything inside every "n" ticks and tweaks its spoilage status, but that's going to start tanking performance if you use it at scale. I generally don't like using on_tick events for that reason.

4 months ago

Yeah it sounds like except for making an item that as soon as it detects existing instantly do the things, which would be manual and annoying as heck to do because you would either need one for every special output or have one which can trigger different things...

So that is most likely a dead end. Though that blacklisting feature would be nice, I've seen one in a mod for invulnerable rails which allowed you to simply say the name of an item and it would make them invulnerable. In here it would either just ignore removing it from this item or preserve temporarily as the others are being deleted before readding the spoiling to that item.

4 months ago

Yeah, a blacklist is the best, most robust option. It's fairly trivial to implement, but it would need to be written into the Whats a Spoilage mod. I encourage you to post a request on that mod's discussions page in the hopes that the author will add that.

4 months ago

I will do that, just a in like 8 hours since I gotta sleep now, I'm abroad, so in the morning I should have time and energy to ask in a non dramatic manner

3 months ago

Well, I ended up making a brand new mod which does everything I wanted and the blacklist that you wanted. It's called No Timed Spoilage and comes with a few customisation settings, as well as a new building. Honestly, it does everything this mod does, but better. I'm thinking of setting this mod to "Deprecated" because I really don't see the point in using it over No Timed Spoilage.

New response