Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Script to force food to rot  (Read 1842 times)

samanato

  • Bay Watcher
  • @ Gardevoirite
    • View Profile
Script to force food to rot
« on: December 03, 2014, 05:43:07 am »

Hi all,

I wanted to use a script for a hard food industry mod, that forces rottable food items to rot anywhere, even a stockpile. Putnam gave me these three lines of code (just a single call if I read this right), which should make the rot timer on all rottable food items count down.  For some reason it doesn't appear to work though.  Normally unattended items rot in a fortnight, and ideally I would like it to happen in a month or less while stored, but even after three months of being stored in a stockpile all items are intact.

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

I named the script foodrot.lua and in the onLoad.init called "footrot enable". I'm not sure if the call is running too slowly (not incrementing through all items at once, as he suggested) or if it's not registering at all, maybe because of the item vector itself (also suggested), or some other problem?
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: Script to force food to rot
« Reply #1 on: December 03, 2014, 11:31:23 am »

Food rot timers are reset as long as they're sitting on a stockpile, so you'll need to use some other method.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

pisskop

  • Bay Watcher
  • Too old and stubborn to get a new avatar
    • View Profile
Re: Script to force food to rot
« Reply #2 on: December 03, 2014, 11:34:35 am »

Could you make extra vicious vermin?
Logged
Pisskop's Reblancing Mod - A C:DDA Mod to make life a little (lot) more brutal!
drealmerz7 - pk was supreme pick for traitor too I think, and because of how it all is and pk is he is just feeding into the trollfucking so well.
PKs DF Mod!

samanato

  • Bay Watcher
  • @ Gardevoirite
    • View Profile
Re: Script to force food to rot
« Reply #3 on: December 04, 2014, 10:15:44 am »

Food rot timers are reset as long as they're sitting on a stockpile, so you'll need to use some other method.

Ah, too bad.  If that doesn't work, I'm thinking of replacing the rot timer call with the wear timer, which if I remember does work in stockpiles.  It would ideally take longer for food to "rot" in this manner, maybe reaching the x's at about 3 weeks & completely deteriorating after two(?) months.  Not sure, how the variables for the wear timer call work though.
« Last Edit: December 07, 2014, 04:28:33 pm by samanato »
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: Script to force food to rot
« Reply #4 on: December 04, 2014, 10:41:33 am »

Food rot timers are reset as long as they're sitting on a stockpile, so you'll need to use some other method.
Is there a way to just set the rot timer directly, or better yet just flag something a rotten?  I don't recall stockpiles having the magical ability to freshen already-rotten food.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

samanato

  • Bay Watcher
  • @ Gardevoirite
    • View Profile
Re: Script to force food to rot
« Reply #5 on: December 07, 2014, 04:39:23 pm »

Is there a way to just set the rot timer directly, or better yet just flag something a rotten?  I don't recall stockpiles having the magical ability to freshen already-rotten food.

Testing with the lua printall, the rot-timer is just permanently stuck to 1 when it's in a stockpile.

It might be a better idea, to just directly switch the rotten flag on after the item passes a certain age. Would like to know too, if it's possible to modify the script to do this.
Logged

Askot Bokbondeler

  • Bay Watcher
  • please line up orderly
    • View Profile
Re: Script to force food to rot
« Reply #6 on: December 16, 2014, 05:06:39 am »

ptw

Button

  • Bay Watcher
  • Plants Specialist
    • View Profile
Re: Script to force food to rot
« Reply #7 on: May 27, 2015, 12:27:21 pm »

Necroing to let watchers know that someone has made a script that does this. http://www.bay12forums.com/smf/index.php?topic=150782.0
Logged
I used to work on Modest Mod and Plant Fixes.

Always assume I'm not seriously back

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Script to force food to rot
« Reply #8 on: May 27, 2015, 03:46:25 pm »

That's very neat, and yeah, it should be mentioned over here too.
Logged