diff --git a/advtools.lua b/advtools.lua index 9f4d2ec3b..6c8cd9fcf 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 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 622273520..80bb1a3c7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -31,6 +31,8 @@ Template for new versions: ## New Features ## Fixes +- `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 diff --git a/ghostly.lua b/ghostly.lua index 2813d8aec..1de956295 100644 --- a/ghostly.lua +++ b/ghostly.lua @@ -1,9 +1,7 @@ -if not dfhack.world.isAdventureMode() then - qerror('This script must be used in adventure mode') -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 d9b3eaa16..354aaea00 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 = 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 @@ -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, } @@ -246,7 +246,7 @@ end function Notify:refresh() local choices = {} - local is_adv = dfhack.world.isAdventureMode() + 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/gui/reveal.lua b/gui/reveal.lua index f9e636ceb..2a8476c49 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 fdf9cb5bd..53a0fbf07 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 = 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 942dde409..03326cc0b 100644 --- a/launch.lua +++ b/launch.lua @@ -4,9 +4,6 @@ local guidm = require('gui.dwarfmode') function launch(unitSource,unitRider) - if not dfhack.world.isAdventureMode() 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 61da34c46..e7e0e5b25 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 = df.global.gamemode == df.game_mode.ADVENTURE local screen = dfhack.gui.getDFViewscreen() local windowSize = dfhack.screen.getWindowSize() diff --git a/resize-armor.lua b/resize-armor.lua index 1735520c9..faa7d69c9 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 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 dfhack.world.isAdventureMode() 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 ( - not dfhack.world.isAdventureMode() 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 ce317fe08..d23bfa393 100644 --- a/resurrect-adv.lua +++ b/resurrect-adv.lua @@ -1,11 +1,9 @@ local fullHeal = reqscript('full-heal') -if not dfhack.world.isAdventureMode() then - qerror("This script can only be used in adventure mode!") -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 @@ -13,4 +11,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 3033049db..90bf3529c 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 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.'))