summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-09-20 11:11:59 +0400
committerAlexander Gavrilov2012-09-20 11:11:59 +0400
commit462bedb75708043f3ef9520e8fb84640ebaec945 (patch)
treefeebdbfbb25e0a4611dd8c54b69c15d8aac3f57f /scripts
parentc39a33722316ee91f7a42abcd76149788dd19196 (diff)
downloaddfhack-462bedb75708043f3ef9520e8fb84640ebaec945.tar.gz
dfhack-462bedb75708043f3ef9520e8fb84640ebaec945.tar.bz2
dfhack-462bedb75708043f3ef9520e8fb84640ebaec945.tar.xz
Fix the rename plugin and script to use the new getSelectedBuilding API.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gui/rename.lua10
-rw-r--r--scripts/gui/siege-engine.lua4
2 files changed, 9 insertions, 5 deletions
diff --git a/scripts/gui/rename.lua b/scripts/gui/rename.lua
index a457a0bf..70a09b2f 100644
--- a/scripts/gui/rename.lua
+++ b/scripts/gui/rename.lua
@@ -13,10 +13,12 @@ local function verify_mode(expected)
end
end
-if string.match(focus, '^dwarfmode/QueryBuilding/Some') then
+local unit = dfhack.gui.getSelectedUnit(true)
+local building = dfhack.gui.getSelectedBuilding(true)
+
+if building and (not unit or mode == 'building') then
verify_mode('building')
- local building = df.global.world.selected_building
if plugin.canRenameBuilding(building) then
dlg.showInputPrompt(
'Rename Building',
@@ -30,9 +32,7 @@ if string.match(focus, '^dwarfmode/QueryBuilding/Some') then
'Cannot rename this type of building.', COLOR_LIGHTRED
)
end
-elseif dfhack.gui.getSelectedUnit(true) then
- local unit = dfhack.gui.getSelectedUnit(true)
-
+elseif unit then
if mode == 'unit-profession' then
dlg.showInputPrompt(
'Rename Unit',
diff --git a/scripts/gui/siege-engine.lua b/scripts/gui/siege-engine.lua
index c98cb167..f460bb21 100644
--- a/scripts/gui/siege-engine.lua
+++ b/scripts/gui/siege-engine.lua
@@ -74,6 +74,10 @@ function SiegeEngine:onDestroy()
end
end
+function SiegeEngine:onGetSelectedBuilding()
+ return df.global.world.selected_building
+end
+
function SiegeEngine:showCursor(enable)
local cursor = guidm.getCursorPos()
if cursor and not enable then