Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion advtools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions ghostly.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions gui/notify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gui/reveal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion internal/unit-info-viewer/skills-progress.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions launch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions resize-armor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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.')
Expand All @@ -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.')
Expand Down
10 changes: 4 additions & 6 deletions resurrect-adv.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
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

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
2 changes: 1 addition & 1 deletion toggle-kbd-cursor.lua
Original file line number Diff line number Diff line change
@@ -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.'))
Expand Down
Loading