Skip to content

Commit cc2dc94

Browse files
committed
add notification for stuck squad and a player needs to take action
1 parent e64a88e commit cc2dc94

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

internal/notify/notifications.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
--@module = true
22

3+
local dlg = require('gui.dialogs')
34
local gui = require('gui')
45
local json = require('json')
56
local list_agreements = reqscript('list-agreements')
7+
local repeat_util = require('repeat-util')
8+
local stuck_squad = reqscript('fix/stuck-squad')
69
local warn_stranded = reqscript('warn-stranded')
710

811
local CONFIG_FILE = 'dfhack-config/notify.json'
@@ -302,6 +305,34 @@ end
302305

303306
-- the order of this list controls the order the notifications will appear in the overlay
304307
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+
},
305336
{
306337
name='traders_ready',
307338
desc='Notifies when traders are ready to trade at the depot.',

0 commit comments

Comments
 (0)