forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautounsuspend.lua
More file actions
36 lines (28 loc) · 819 Bytes
/
autounsuspend.lua
File metadata and controls
36 lines (28 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- automate periodic running of the unsuspend script
--[====[
autounsuspend
=============
Periodically check construction jobs and keep them unsuspended with the
`unsuspend` script.
]====]
local repeatUtil = require 'repeat-util'
local job_name = '__autounsuspend'
local function help()
print('syntax: autounsuspend [start|stop]')
end
local function stop()
repeatUtil.cancel(job_name)
print('autounsuspend Stopped.')
end
local function start()
local unsuspend_fn = function() dfhack.run_script('unsuspend') end
repeatUtil.scheduleEvery(job_name, '1', 'days', unsuspend_fn)
print('autounsuspend Running.')
end
local action_switch = {
start=start,
stop=stop,
}
setmetatable(action_switch, {__index=function() return help end})
local args = {...}
action_switch[args[1] or 'help']()