2012-11-20 07:41:35 -07:00
|
|
|
class AutoUnsuspend
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
|
|
|
|
def process
|
|
|
|
return false unless @running
|
|
|
|
joblist = df.world.job_list.next
|
|
|
|
count = 0
|
|
|
|
|
|
|
|
while joblist
|
|
|
|
job = joblist.item
|
|
|
|
joblist = joblist.next
|
|
|
|
|
|
|
|
if job.job_type == :ConstructBuilding
|
|
|
|
if (job.flags.suspend)
|
|
|
|
item = job.items[0].item
|
|
|
|
job.flags.suspend = false
|
|
|
|
count += 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "Unsuspended #{count} job(s)." unless count == 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def start
|
2012-11-24 08:05:03 -07:00
|
|
|
@onupdate = df.onupdate_register('autounsuspend', 5) { process }
|
2012-11-20 07:41:35 -07:00
|
|
|
@running = true
|
|
|
|
end
|
|
|
|
|
|
|
|
def stop
|
|
|
|
df.onupdate_unregister(@onupdate)
|
|
|
|
@running = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def status
|
2012-11-24 08:05:03 -07:00
|
|
|
@running ? 'Running.' : 'Stopped.'
|
2012-11-20 07:41:35 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
case $script_args[0]
|
|
|
|
when 'start'
|
|
|
|
$AutoUnsuspend = AutoUnsuspend.new unless $AutoUnsuspend
|
|
|
|
$AutoUnsuspend.start
|
|
|
|
|
|
|
|
when 'end', 'stop'
|
|
|
|
$AutoUnsuspend.stop
|
|
|
|
|
|
|
|
else
|
|
|
|
if $AutoUnsuspend
|
|
|
|
puts $AutoUnsuspend.status
|
|
|
|
else
|
2012-11-24 08:05:03 -07:00
|
|
|
puts 'Not loaded.'
|
2012-11-20 07:41:35 -07:00
|
|
|
end
|
|
|
|
end
|