Skip to content

Commit

Permalink
add notification for stuck squad and a player needs to take action
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Dec 25, 2024
1 parent e64a88e commit cc2dc94
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions internal/notify/notifications.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
--@module = true

local dlg = require('gui.dialogs')
local gui = require('gui')
local json = require('json')
local list_agreements = reqscript('list-agreements')
local repeat_util = require('repeat-util')
local stuck_squad = reqscript('fix/stuck-squad')
local warn_stranded = reqscript('warn-stranded')

local CONFIG_FILE = 'dfhack-config/notify.json'
Expand Down Expand Up @@ -302,6 +305,34 @@ end

-- the order of this list controls the order the notifications will appear in the overlay
NOTIFICATIONS_BY_IDX = {
{
name='stuck_squad',
desc='Notifies when a squad is stuck on the world map.',
default=true,
dwarf_fn=function()
local stuck_armies, outbound_army, returning_army = stuck_squad.scan_fort_armies()
if #stuck_armies == 0 then return end
if repeat_util.isScheduled('control-panel/fix/stuck-squad') and (outbound_army or returning_army) then
return
end
return ('%d squad%s need%s rescue'):format(
#stuck_armies,
#stuck_armies == 1 and '' or 's',
#stuck_armies == 1 and 's' or ''
)
end,
on_click=function()
local message = 'A squad is lost on the world map and needs rescue!\n\n' ..
'Please send a squad out on a mission that will return to the fort.\n' ..
'They will rescue the stuck squad on their way home.'
if not repeat_util.isScheduled('control-panel/fix/stuck-squad') then
message = message .. '\n\n' ..
'Please enable fix/stuck-squad in the DFHack control panel to allow\n'..
'the rescue mission to happen.'
end
dlg.showMessage('Rescue stuck squads', message, COLOR_WHITE)
end,
},
{
name='traders_ready',
desc='Notifies when traders are ready to trade at the depot.',
Expand Down

0 comments on commit cc2dc94

Please sign in to comment.