Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Making food rot inside containers  (Read 1471 times)

samanato

  • Bay Watcher
  • @ Gardevoirite
    • View Profile
Making food rot inside containers
« on: November 04, 2014, 10:04:16 pm »

I'm working on a new (actually old, and at least twice completely redone) mod, which has a much more precarious food industry as one of its main features (the other one is supernatural weirdness), one of the features being the need to preserve food for long-term storage.  Problem with such a thing is, how you can indefinitely store things in a stockpile and a pot without worry of it spoiling.  I've only got around this now by denying meat and fat stockpile options and forcing them to rot, but eventually I want to extend this to prepared fish, fruit, and vegetables, and what I have now for meat is not an ideal solution for various reasons. 

Is there a practicable way to force food to wither/rot even inside a stockpile, with DFhack or otherwise? I remember something with heat damage to simulate degradation at non-freezing temperatures, but this appears to cause problems with creatures.  Also no miasma.
« Last Edit: November 04, 2014, 10:28:06 pm by samanato »
Logged

Button

  • Bay Watcher
  • Plants Specialist
    • View Profile
Re: Making food rot inside containers
« Reply #1 on: November 05, 2014, 02:50:28 am »

PTW.
Logged
I used to work on Modest Mod and Plant Fixes.

Always assume I'm not seriously back

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Making food rot inside containers
« Reply #2 on: November 05, 2014, 04:20:49 am »

Only way's through DFHack.

Code: [Select]
for _,item in ipairs(df.global.world.items.other.ANY_CAN_ROT) do
    item:incrementRotTimer()
end

...well that was pretty friggin easy. I don't know how often the rot timer is incremented in-game, though; if it's normally once a tick, you'll have either a performance issue (incrementing through every rottable item once a tick) or super-slowly rotting items (not incrementing through all of 'em). Similarly, if the ANY_CAN_ROT vector only contains items that are eligible for rotting, the above will have no effect except making things that are already rotting rot faster. I doubt that's the case, however.

The logic for repeating every few ticks can be seen in... various places, it's too late for me to write more code than a single call to a vmethod right now.

samanato

  • Bay Watcher
  • @ Gardevoirite
    • View Profile
Re: Making food rot inside containers
« Reply #3 on: November 05, 2014, 02:39:42 pm »

Only way's through DFHack.

Code: [Select]
for _,item in ipairs(df.global.world.items.other.ANY_CAN_ROT) do
    item:incrementRotTimer()
end

...well that was pretty friggin easy. I don't know how often the rot timer is incremented in-game, though; if it's normally once a tick, you'll have either a performance issue (incrementing through every rottable item once a tick) or super-slowly rotting items (not incrementing through all of 'em). Similarly, if the ANY_CAN_ROT vector only contains items that are eligible for rotting, the above will have no effect except making things that are already rotting rot faster. I doubt that's the case, however.

The logic for repeating every few ticks can be seen in... various places, it's too late for me to write more code than a single call to a vmethod right now.

Thanks.  Also, what is the item flag for preserved items (the kind, that underground tribes eat)? I was thinking of using a simple script to turn the preserved flag on and hook it to a reaction, instead of doubling material definitions.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Making food rot inside containers
« Reply #5 on: November 05, 2014, 06:23:55 pm »

I look for that flag once upon a time, and it appears to be one of the ones that is "unknown". Find a preserved item and inspect it with the "lua" command to see what flags are set (printall is your friend), maybe you can isolate it, I never tried all that hard.

Once you figure out which flag it is tell us! Making preserved items sounds like a cool extension for the kitchen (stock your emergency bunker today!).
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Askot Bokbondeler

  • Bay Watcher
  • please line up orderly
    • View Profile
Re: Making food rot inside containers
« Reply #6 on: November 22, 2014, 02:31:25 pm »

ptw

samanato

  • Bay Watcher
  • @ Gardevoirite
    • View Profile
Re: Making food rot inside containers
« Reply #7 on: November 23, 2014, 12:10:51 am »

Animalmen don't appear to carry food with them anymore.  Generating a world with vanilla raws and using DFHack to reveal the units on the map shows the tribes, but no items strewn about as they were in .34.11. Might try finding the flag in .34.11, but I'm not sure, if it's still even there anymore.

Preserving items is still possible without custom scripts, just needs more workarounds and materials being defined. Vegetable pickles can't easily use the same items as plant growths, since the material is inherently tied to the growth itself, but they can be defined as [CHEESE_PLANT] for easy stockpiling (and it's at least tangentially similar, being a fermented product). Fish and eggs are more challenging, especially since that the FISH item token is broken. I don't remember, how the rotting behaviour for fish works (tied to the creature materials? hardcoded?)

EDIT: Tested this with createitem in arena; fish items rot only when the creature itself has some material that can rot. Running "createitem FISH WAGON:DEFAULT" makes a prepared wagon fish, and since its only material is wood, the item never rots.

Strangely enough, normal fish are "made of" things like bone, cartilage or chitin. You can even link a material reaction product to a vermin fish's bone and get that product, when you run the reaction using the whole fish as reagent.
« Last Edit: November 25, 2014, 02:03:17 am by samanato »
Logged

samanato

  • Bay Watcher
  • @ Gardevoirite
    • View Profile
Re: Making food rot inside containers
« Reply #8 on: November 28, 2014, 12:08:25 am »

Sorry the double-post. Appears, the rotting increment call is either not registering altogether or ticking down too slowly. It normally takes about two weeks for an item to rot (presumably for the rotting timer to completely tick down), but already rotting items left on the floor don't rot any faster, and stockpiled ones are intact after a full month.
Logged