|
1 | 1 | --@module = true |
2 | 2 |
|
| 3 | +local dlg = require('gui.dialogs') |
3 | 4 | local gui = require('gui') |
4 | 5 | local json = require('json') |
5 | 6 | local list_agreements = reqscript('list-agreements') |
| 7 | +local repeat_util = require('repeat-util') |
| 8 | +local stuck_squad = reqscript('fix/stuck-squad') |
6 | 9 | local warn_stranded = reqscript('warn-stranded') |
7 | 10 |
|
8 | 11 | local CONFIG_FILE = 'dfhack-config/notify.json' |
|
302 | 305 |
|
303 | 306 | -- the order of this list controls the order the notifications will appear in the overlay |
304 | 307 | NOTIFICATIONS_BY_IDX = { |
| 308 | + { |
| 309 | + name='stuck_squad', |
| 310 | + desc='Notifies when a squad is stuck on the world map.', |
| 311 | + default=true, |
| 312 | + dwarf_fn=function() |
| 313 | + local stuck_armies, outbound_army, returning_army = stuck_squad.scan_fort_armies() |
| 314 | + if #stuck_armies == 0 then return end |
| 315 | + if repeat_util.isScheduled('control-panel/fix/stuck-squad') and (outbound_army or returning_army) then |
| 316 | + return |
| 317 | + end |
| 318 | + return ('%d squad%s need%s rescue'):format( |
| 319 | + #stuck_armies, |
| 320 | + #stuck_armies == 1 and '' or 's', |
| 321 | + #stuck_armies == 1 and 's' or '' |
| 322 | + ) |
| 323 | + end, |
| 324 | + on_click=function() |
| 325 | + local message = 'A squad is lost on the world map and needs rescue!\n\n' .. |
| 326 | + 'Please send a squad out on a mission that will return to the fort.\n' .. |
| 327 | + 'They will rescue the stuck squad on their way home.' |
| 328 | + if not repeat_util.isScheduled('control-panel/fix/stuck-squad') then |
| 329 | + message = message .. '\n\n' .. |
| 330 | + 'Please enable fix/stuck-squad in the DFHack control panel to allow\n'.. |
| 331 | + 'the rescue mission to happen.' |
| 332 | + end |
| 333 | + dlg.showMessage('Rescue stuck squads', message, COLOR_WHITE) |
| 334 | + end, |
| 335 | + }, |
305 | 336 | { |
306 | 337 | name='traders_ready', |
307 | 338 | desc='Notifies when traders are ready to trade at the depot.', |
|
0 commit comments