2014-06-26 06:36:57 -06:00
|
|
|
-- feeding-timers.lua
|
2015-04-06 09:25:30 -06:00
|
|
|
-- original author: tejón
|
2014-06-26 06:36:57 -06:00
|
|
|
-- rewritten by expwnent
|
|
|
|
-- see repeat.lua for how to run this every so often automatically
|
2015-10-23 08:37:39 -06:00
|
|
|
--[[=begin
|
2014-06-26 06:36:57 -06:00
|
|
|
|
2015-10-23 08:37:39 -06:00
|
|
|
fix/feeding-timers
|
|
|
|
==================
|
|
|
|
Reset the GiveWater and GiveFood timers of all units as appropriate.
|
|
|
|
|
|
|
|
=end]]
|
2014-06-26 06:36:57 -06:00
|
|
|
local args = {...}
|
|
|
|
if args[1] ~= nil then
|
2014-06-27 01:46:22 -06:00
|
|
|
print("fix/feeding-timers usage")
|
|
|
|
print(" fix/feeding-timers")
|
2014-06-26 06:36:57 -06:00
|
|
|
print(" reset the feeding timers of all units as appropriate")
|
2014-06-27 01:46:22 -06:00
|
|
|
print(" fix/feeding-timers help")
|
2014-06-26 06:36:57 -06:00
|
|
|
print(" print this help message")
|
2014-06-27 01:46:22 -06:00
|
|
|
print(" repeat -time [n] [years/months/ticks/days/etc] -command fix/feeding-timers")
|
2014-06-26 06:36:57 -06:00
|
|
|
print(" run this script every n time units")
|
2014-06-27 01:46:22 -06:00
|
|
|
print(" repeat -cancel fix/feeding-timers")
|
2014-06-26 06:36:57 -06:00
|
|
|
print(" stop automatically running this script")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local fixcount = 0
|
|
|
|
for _,unit in ipairs(df.global.world.units.all) do
|
|
|
|
if dfhack.units.isCitizen(unit) and not (unit.flags1.dead) then
|
|
|
|
for _,v in pairs(unit.status.misc_traits) do
|
|
|
|
local didfix = 0
|
|
|
|
if v.id == 0 then -- I think this should have additional conditions...
|
|
|
|
v.value = 0 -- GiveWater cooldown set to zero
|
|
|
|
didfix = 1
|
|
|
|
end
|
|
|
|
if v.id == 1 then -- I think this should have additional conditions...
|
|
|
|
v.value = 0 -- GiveFood cooldown set to zero
|
|
|
|
didfix = 1
|
|
|
|
end
|
|
|
|
fixcount = fixcount + didfix
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print("Fixed feeding timers for " .. fixcount .. " citizens.")
|