From 43c29d566018631ff8df27c821594172f7e5aed1 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Sun, 4 Oct 2026 04:43:59 -0700 Subject: [PATCH 1/6] Update scripts to detect arena adventurer * Update launch.lua - Arena * Update ghostly.lua - Arena * Update resurrect-adv.lua - Arena * Update position.lua - Arena * Update resize-armor.lua - Arena * Update toggle-kbd-cursor.lua - Arena * Update markdown.lua - Arena * Update advtools.lua - Arena * Update gui/notify.lua - Arena * Update skills-progress.lua - Arena * Update gui/reveal.lua - Disallow arena * Update changelog.txt --- advtools.lua | 2 +- changelog.txt | 3 +++ ghostly.lua | 4 ++-- gui/notify.lua | 4 ++-- gui/reveal.lua | 2 ++ internal/unit-info-viewer/skills-progress.lua | 2 +- launch.lua | 2 +- markdown.lua | 2 +- position.lua | 2 +- resize-armor.lua | 6 +++--- resurrect-adv.lua | 6 +++--- toggle-kbd-cursor.lua | 2 +- 12 files changed, 21 insertions(+), 16 deletions(-) diff --git a/advtools.lua b/advtools.lua index 9f4d2ec3b3..dbf1305725 100644 --- a/advtools.lua +++ b/advtools.lua @@ -26,7 +26,7 @@ if not command or command == 'help' or not commands[command] then end -- since these are "advtools", maybe don't let them run outside adventure mode. -if not dfhack.world.isAdventureMode() then +if gamemode ~= df.game_mode.ADVENTURER then qerror("This script can only be used during adventure mode!") end commands[command](args) diff --git a/changelog.txt b/changelog.txt index 622273520f..1771326df3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -31,6 +31,9 @@ Template for new versions: ## New Features ## Fixes +- `launch`, `ghostly`, `resurrect-adv`, `position`, `resize-armor`, `toggle-kbd-cursor`, `markdown`, `advtools`, `gui/create-item`, `gui/notify`: now detect arena adventure mode +- `gui/unit-info-viewer`: show skill progress for arena adventurer +- `gui/reveal`: don't allow use in arena, since underlying `reveal` plugin doesn't support it ## Misc Improvements diff --git a/ghostly.lua b/ghostly.lua index 2813d8aec3..a3876e532f 100644 --- a/ghostly.lua +++ b/ghostly.lua @@ -1,5 +1,5 @@ -if not dfhack.world.isAdventureMode() then - qerror('This script must be used in adventure mode') +if gamemode ~= df.game_mode.ADVENTURER then + qerror('This script must be used in adventure mode or the arena!') end local unit = dfhack.world.getAdventurer() diff --git a/gui/notify.lua b/gui/notify.lua index d9b3eaa163..db624bd6f7 100644 --- a/gui/notify.lua +++ b/gui/notify.lua @@ -70,7 +70,7 @@ end function NotifyOverlay:overlay_onupdate() local choices = {} - local is_adv = dfhack.world.isAdventureMode() + local is_adv = gamemode == df.game_mode.ADVENTURER self.critical = false for _, notification in ipairs(notifications.NOTIFICATIONS_BY_IDX) do if not notifications.config.data[notification.name].enabled then goto continue end @@ -246,7 +246,7 @@ end function Notify:refresh() local choices = {} - local is_adv = dfhack.world.isAdventureMode() + local is_adv = gamemode == df.game_mode.ADVENTURER for name, conf in pairs(notifications.config.data) do local notification = notifications.NOTIFICATIONS_BY_NAME[name] if not get_fn(notification, is_adv) then goto continue end diff --git a/gui/reveal.lua b/gui/reveal.lua index f9e636cebd..90d3311907 100644 --- a/gui/reveal.lua +++ b/gui/reveal.lua @@ -123,6 +123,8 @@ end if not dfhack.isMapLoaded() then qerror('This script requires a map to be loaded') +elseif dfhack.world.isArena() then + qerror('This script doesn't work in arena mode') end local opts = {aquifers_only=false} diff --git a/internal/unit-info-viewer/skills-progress.lua b/internal/unit-info-viewer/skills-progress.lua index fdf9cb5bdc..2830281f55 100644 --- a/internal/unit-info-viewer/skills-progress.lua +++ b/internal/unit-info-viewer/skills-progress.lua @@ -90,7 +90,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect) table.insert(annotations, "\n\n") end - local progress_bar_needed = not dfhack.world.isAdventureMode() or not dfhack.screen.inGraphicsMode() + local progress_bar_needed = gamemode ~= df.game_mode.ADVENTURER or not dfhack.screen.inGraphicsMode() self.subviews.toggle_progress.visible = progress_bar_needed local progress_bar = self.subviews.toggle_progress:getOptionValue() and progress_bar_needed local experience = self.subviews.toggle_experience:getOptionValue() diff --git a/launch.lua b/launch.lua index 942dde409e..500d7be914 100644 --- a/launch.lua +++ b/launch.lua @@ -4,7 +4,7 @@ local guidm = require('gui.dwarfmode') function launch(unitSource,unitRider) - if not dfhack.world.isAdventureMode() then + if gamemode ~= df.game_mode.ADVENTURER then qerror("Must be used in adventurer mode or the arena!") end local curpos = guidm.getCursorPos() diff --git a/markdown.lua b/markdown.lua index 61da34c464..4a5d83e6b1 100644 --- a/markdown.lua +++ b/markdown.lua @@ -93,7 +93,7 @@ if item then elseif unit then -- Unit processing -- Simulate UI interactions to load data into memory (click through tabs). Note: Constant might change with DF updates/patches - local is_adv = dfhack.world.isAdventureMode() + local is_adv = gamemode == df.game_mode.ADVENTURER local screen = dfhack.gui.getDFViewscreen() local windowSize = dfhack.screen.getWindowSize() diff --git a/position.lua b/position.lua index 094211fb29..1c26b96a86 100644 --- a/position.lua +++ b/position.lua @@ -77,7 +77,7 @@ local function print_world_info() format(site.pos.x, site.pos.y, wd.world_width, wd.world_height)) end - if dfhack.world.isAdventureMode() then + if gamemode ~= df.game_mode.ADVENTURER then local x, y = get_adv_region_pos() print((' The adventurer is at x=%d, y=%d on the %dx%d world map.'): format(x, y, wd.world_width, wd.world_height)) diff --git a/resize-armor.lua b/resize-armor.lua index 1735520c95..1eeb5aed85 100644 --- a/resize-armor.lua +++ b/resize-armor.lua @@ -58,7 +58,7 @@ end local function GetRace() local race - if dfhack.world.isAdventureMode() then + if gamemode == df.game_mode.ADVENTURER then race = dfhack.world.getAdventurer().race elseif dfhack.world.isFortressMode() then local site = dfhack.world.getCurrentSite() @@ -132,7 +132,7 @@ local function Main(args) end ResizeItems(items, race) else - if dfhack.world.isAdventureMode() then + if gamemode == df.game_mode.ADVENTURER then qerror('No item selected.') elseif dfhack.world.isFortressMode() then qerror('No item or stockpile selected.') @@ -141,7 +141,7 @@ local function Main(args) end if not dfhack.isMapLoaded() or ( - not dfhack.world.isAdventureMode() and not dfhack.world.isFortressMode() + gamemode ~= df.game_mode.ADVENTURER and not dfhack.world.isFortressMode() ) then qerror('This script requires the game to be in adventure or fortress mode.') diff --git a/resurrect-adv.lua b/resurrect-adv.lua index ce317fe082..09efd7afb8 100644 --- a/resurrect-adv.lua +++ b/resurrect-adv.lua @@ -1,7 +1,7 @@ local fullHeal = reqscript('full-heal') -if not dfhack.world.isAdventureMode() then - qerror("This script can only be used in adventure mode!") +if gamemode ~= df.game_mode.ADVENTURER then + qerror("This script can only be used in adventure mode or the arena!") end local adventurer = dfhack.world.getAdventurer() @@ -13,4 +13,4 @@ fullHeal.heal(adventurer, true) -- this ensures that the player will be able to regain control of their unit after -- resurrection if the script is run before hitting DONE at the "You are deceased" message -df.global.adventure.player_control_state = 1 +df.global.adventure.player_control_state = df.adventure_game_loop_type.ENTER diff --git a/toggle-kbd-cursor.lua b/toggle-kbd-cursor.lua index 3033049dbe..49202564b8 100644 --- a/toggle-kbd-cursor.lua +++ b/toggle-kbd-cursor.lua @@ -1,7 +1,7 @@ local gui = require('gui') local guidm = require('gui.dwarfmode') -if dfhack.world.isAdventureMode() then +if gamemode == df.game_mode.ADVENTURER then local open = df.global.game.main_interface.adventure.look.open gui.simulateInput(dfhack.gui.getDFViewscreen(), open and 'LEAVESCREEN' or 'A_LOOK') print('Look mode '..(open and 'disabled.' or 'enabled.')) From a172000ccff6155cf34245c81ff55beef7ea0f73 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Sun, 4 Oct 2026 04:47:40 -0700 Subject: [PATCH 2/6] Update position.lua - Fix inverted condition --- position.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/position.lua b/position.lua index 1c26b96a86..4697576af1 100644 --- a/position.lua +++ b/position.lua @@ -77,7 +77,7 @@ local function print_world_info() format(site.pos.x, site.pos.y, wd.world_width, wd.world_height)) end - if gamemode ~= df.game_mode.ADVENTURER then + if gamemode == df.game_mode.ADVENTURER then local x, y = get_adv_region_pos() print((' The adventurer is at x=%d, y=%d on the %dx%d world map.'): format(x, y, wd.world_width, wd.world_height)) From 98b0a8d0545e30a74ff324896540282431661289 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Sun, 4 Oct 2026 12:50:49 -0700 Subject: [PATCH 3/6] Update reveal.lua - Fix error string --- gui/reveal.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/reveal.lua b/gui/reveal.lua index 90d3311907..2a8476c49a 100644 --- a/gui/reveal.lua +++ b/gui/reveal.lua @@ -124,7 +124,7 @@ end if not dfhack.isMapLoaded() then qerror('This script requires a map to be loaded') elseif dfhack.world.isArena() then - qerror('This script doesn't work in arena mode') + qerror('This script doesn\'t work in arena mode') end local opts = {aquifers_only=false} From 97b0f6500b8ca2c9652531e4c5c55f8b16727d09 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Mon, 5 Oct 2026 01:36:49 -0700 Subject: [PATCH 4/6] Fix gamemode checks, revert position.lua * Update position.lua - Revert, no meaningful arena position * Update changelog.txt - Revert position * Update advtools.lua * Update ghostly.lua * Update notify.lua * Update skills-progress.lua * Update launch.lua * Update markdown.lua * Update resize-armor.lua * Update resurrect-adv.lua * Update toggle-kbd-cursor.lua --- advtools.lua | 2 +- changelog.txt | 2 +- ghostly.lua | 8 +++----- gui/notify.lua | 4 ++-- internal/unit-info-viewer/skills-progress.lua | 2 +- launch.lua | 7 +++---- markdown.lua | 2 +- position.lua | 2 +- resize-armor.lua | 6 +++--- resurrect-adv.lua | 8 +++----- toggle-kbd-cursor.lua | 2 +- 11 files changed, 20 insertions(+), 25 deletions(-) diff --git a/advtools.lua b/advtools.lua index dbf1305725..6c8cd9fcf9 100644 --- a/advtools.lua +++ b/advtools.lua @@ -26,7 +26,7 @@ if not command or command == 'help' or not commands[command] then end -- since these are "advtools", maybe don't let them run outside adventure mode. -if gamemode ~= df.game_mode.ADVENTURER then +if df.global.gamemode ~= df.game_mode.ADVENTURE then qerror("This script can only be used during adventure mode!") end commands[command](args) diff --git a/changelog.txt b/changelog.txt index 1771326df3..08106adbf2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -31,7 +31,7 @@ Template for new versions: ## New Features ## Fixes -- `launch`, `ghostly`, `resurrect-adv`, `position`, `resize-armor`, `toggle-kbd-cursor`, `markdown`, `advtools`, `gui/create-item`, `gui/notify`: now detect arena adventure mode +- `launch`, `ghostly`, `resurrect-adv`, `resize-armor`, `toggle-kbd-cursor`, `markdown`, `advtools`, `gui/create-item`, `gui/notify`: now detect arena adventure mode - `gui/unit-info-viewer`: show skill progress for arena adventurer - `gui/reveal`: don't allow use in arena, since underlying `reveal` plugin doesn't support it diff --git a/ghostly.lua b/ghostly.lua index a3876e532f..1de9562958 100644 --- a/ghostly.lua +++ b/ghostly.lua @@ -1,9 +1,7 @@ -if gamemode ~= df.game_mode.ADVENTURER then - qerror('This script must be used in adventure mode or the arena!') -end - local unit = dfhack.world.getAdventurer() -if unit then +if not unit then + qerror('This script must be used in adventure mode or adventure arena!') +else if unit.flags1.inactive then unit.flags1.inactive = false unit.flags3.ghostly = true diff --git a/gui/notify.lua b/gui/notify.lua index db624bd6f7..f438c317d9 100644 --- a/gui/notify.lua +++ b/gui/notify.lua @@ -70,7 +70,7 @@ end function NotifyOverlay:overlay_onupdate() local choices = {} - local is_adv = gamemode == df.game_mode.ADVENTURER + local is_adv = df.global.gamemode == df.game_mode.ADVENTURE self.critical = false for _, notification in ipairs(notifications.NOTIFICATIONS_BY_IDX) do if not notifications.config.data[notification.name].enabled then goto continue end @@ -246,7 +246,7 @@ end function Notify:refresh() local choices = {} - local is_adv = gamemode == df.game_mode.ADVENTURER + local is_adv = df.global.gamemode == df.game_mode.ADVENTURE for name, conf in pairs(notifications.config.data) do local notification = notifications.NOTIFICATIONS_BY_NAME[name] if not get_fn(notification, is_adv) then goto continue end diff --git a/internal/unit-info-viewer/skills-progress.lua b/internal/unit-info-viewer/skills-progress.lua index 2830281f55..53a0fbf07b 100644 --- a/internal/unit-info-viewer/skills-progress.lua +++ b/internal/unit-info-viewer/skills-progress.lua @@ -90,7 +90,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect) table.insert(annotations, "\n\n") end - local progress_bar_needed = gamemode ~= df.game_mode.ADVENTURER or not dfhack.screen.inGraphicsMode() + local progress_bar_needed = df.global.gamemode ~= df.game_mode.ADVENTURE or not dfhack.screen.inGraphicsMode() self.subviews.toggle_progress.visible = progress_bar_needed local progress_bar = self.subviews.toggle_progress:getOptionValue() and progress_bar_needed local experience = self.subviews.toggle_experience:getOptionValue() diff --git a/launch.lua b/launch.lua index 500d7be914..03326cc0b6 100644 --- a/launch.lua +++ b/launch.lua @@ -4,9 +4,6 @@ local guidm = require('gui.dwarfmode') function launch(unitSource,unitRider) - if gamemode ~= df.game_mode.ADVENTURER then - qerror("Must be used in adventurer mode or the arena!") - end local curpos = guidm.getCursorPos() if not curpos then qerror("No cursor located! You would have slammed into the ground and exploded.") @@ -77,7 +74,9 @@ end local unitSource = dfhack.world.getAdventurer() local unitRider = nil --as:df.unit -if unitSource.job.hunt_target ~= nil then +if not unitSource then + qerror("Must be used in adventurer mode or adventure arena!") +elseif unitSource.job.hunt_target ~= nil then unitRider = unitSource unitSource = unitSource.job.hunt_target unitSource.general_refs:insert("#",{new=df.general_ref_unit_riderst,unit_id=unitRider.id}) diff --git a/markdown.lua b/markdown.lua index 4a5d83e6b1..e7e0e5b25c 100644 --- a/markdown.lua +++ b/markdown.lua @@ -93,7 +93,7 @@ if item then elseif unit then -- Unit processing -- Simulate UI interactions to load data into memory (click through tabs). Note: Constant might change with DF updates/patches - local is_adv = gamemode == df.game_mode.ADVENTURER + local is_adv = df.global.gamemode == df.game_mode.ADVENTURE local screen = dfhack.gui.getDFViewscreen() local windowSize = dfhack.screen.getWindowSize() diff --git a/position.lua b/position.lua index 4697576af1..094211fb29 100644 --- a/position.lua +++ b/position.lua @@ -77,7 +77,7 @@ local function print_world_info() format(site.pos.x, site.pos.y, wd.world_width, wd.world_height)) end - if gamemode == df.game_mode.ADVENTURER then + if dfhack.world.isAdventureMode() then local x, y = get_adv_region_pos() print((' The adventurer is at x=%d, y=%d on the %dx%d world map.'): format(x, y, wd.world_width, wd.world_height)) diff --git a/resize-armor.lua b/resize-armor.lua index 1eeb5aed85..faa7d69c9f 100644 --- a/resize-armor.lua +++ b/resize-armor.lua @@ -58,7 +58,7 @@ end local function GetRace() local race - if gamemode == df.game_mode.ADVENTURER then + if df.global.gamemode == df.game_mode.ADVENTURE then race = dfhack.world.getAdventurer().race elseif dfhack.world.isFortressMode() then local site = dfhack.world.getCurrentSite() @@ -132,7 +132,7 @@ local function Main(args) end ResizeItems(items, race) else - if gamemode == df.game_mode.ADVENTURER then + if df.global.gamemode == df.game_mode.ADVENTURE then qerror('No item selected.') elseif dfhack.world.isFortressMode() then qerror('No item or stockpile selected.') @@ -141,7 +141,7 @@ local function Main(args) end if not dfhack.isMapLoaded() or ( - gamemode ~= df.game_mode.ADVENTURER and not dfhack.world.isFortressMode() + df.global.gamemode ~= df.game_mode.ADVENTURE and not dfhack.world.isFortressMode() ) then qerror('This script requires the game to be in adventure or fortress mode.') diff --git a/resurrect-adv.lua b/resurrect-adv.lua index 09efd7afb8..d23bfa393d 100644 --- a/resurrect-adv.lua +++ b/resurrect-adv.lua @@ -1,11 +1,9 @@ local fullHeal = reqscript('full-heal') -if gamemode ~= df.game_mode.ADVENTURER then - qerror("This script can only be used in adventure mode or the arena!") -end - local adventurer = dfhack.world.getAdventurer() -if not adventurer or not adventurer.flags2.killed then +if not adventurer then + qerror("This script can only be used in adventure mode or adventure arena!") +elseif not adventurer.flags2.killed then qerror("Your adventurer hasn't died yet!") end diff --git a/toggle-kbd-cursor.lua b/toggle-kbd-cursor.lua index 49202564b8..90bf3529c4 100644 --- a/toggle-kbd-cursor.lua +++ b/toggle-kbd-cursor.lua @@ -1,7 +1,7 @@ local gui = require('gui') local guidm = require('gui.dwarfmode') -if gamemode == df.game_mode.ADVENTURER then +if df.global.gamemode == df.game_mode.ADVENTURE then local open = df.global.game.main_interface.adventure.look.open gui.simulateInput(dfhack.gui.getDFViewscreen(), open and 'LEAVESCREEN' or 'A_LOOK') print('Look mode '..(open and 'disabled.' or 'enabled.')) From efde2fffe72680b9aeee6a983b527030ffa67df8 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Mon, 5 Oct 2026 01:42:30 -0700 Subject: [PATCH 5/6] Update changelog.txt --- changelog.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 08106adbf2..80bb1a3c7d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -31,8 +31,7 @@ Template for new versions: ## New Features ## Fixes -- `launch`, `ghostly`, `resurrect-adv`, `resize-armor`, `toggle-kbd-cursor`, `markdown`, `advtools`, `gui/create-item`, `gui/notify`: now detect arena adventure mode -- `gui/unit-info-viewer`: show skill progress for arena adventurer +- `launch`, `ghostly`, `resurrect-adv`, `resize-armor`, `toggle-kbd-cursor`, `markdown`, `advtools`, `gui/create-item`, `gui/notify`, `gui/unit-info-viewer`: now detect arena adventure mode - `gui/reveal`: don't allow use in arena, since underlying `reveal` plugin doesn't support it ## Misc Improvements From 4035a070c3ec7f1b1d625cdbae3f5530dd00d937 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Mon, 5 Oct 2026 11:28:51 -0700 Subject: [PATCH 6/6] Update notify.lua - Enable for adv arena viewscreen --- gui/notify.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/notify.lua b/gui/notify.lua index f438c317d9..354aaea004 100644 --- a/gui/notify.lua +++ b/gui/notify.lua @@ -154,7 +154,7 @@ AdvNotifyOverlay = defclass(AdvNotifyOverlay, NotifyOverlay) AdvNotifyOverlay.ATTRS{ desc='Shows list of active notifications in adventure mode.', default_pos={x=18,y=-5}, - viewscreens='dungeonmode/Default', + viewscreens={'dungeonmode/Default','dungeonmode/ADVENTURE_ARENA'}, overlay_onupdate_max_freq_seconds=1, right_offset=13, }