diff options
| author | Alexander Gavrilov | 2012-08-24 13:49:22 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-08-24 13:49:22 +0400 |
| commit | d52c54cc762e4f525b4d1f3c339e9cf5a1230ee7 (patch) | |
| tree | c5451c6fc216fd73db2db5e3c1ce69e2e94780e0 /library/lua | |
| parent | 296f82b02fcd0801d6614bb45da05c88ed7c88d2 (diff) | |
| download | dfhack-d52c54cc762e4f525b4d1f3c339e9cf5a1230ee7.tar.gz dfhack-d52c54cc762e4f525b4d1f3c339e9cf5a1230ee7.tar.bz2 dfhack-d52c54cc762e4f525b4d1f3c339e9cf5a1230ee7.tar.xz | |
Pull some minor stuff from mechanisms into main libs.
Diffstat (limited to 'library/lua')
| -rw-r--r-- | library/lua/gui/dwarfmode.lua | 14 | ||||
| -rw-r--r-- | library/lua/utils.lua | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/library/lua/gui/dwarfmode.lua b/library/lua/gui/dwarfmode.lua index b5ffa728..c1a8bcb9 100644 --- a/library/lua/gui/dwarfmode.lua +++ b/library/lua/gui/dwarfmode.lua @@ -3,6 +3,8 @@ local _ENV = mkmodule('gui.dwarfmode') local gui = require('gui') +local utils = require('utils') + local dscreen = dfhack.screen local world_map = df.global.world.map @@ -187,6 +189,18 @@ function DwarfOverlay:getViewport(old_vp) end end +function DwarfOverlay:moveCursorTo(cursor,viewport) + setCursorPos(cursor) + self:getViewport(viewport):reveal(cursor, 5, 0, 10):set() +end + +function DwarfOverlay:selectBuilding(building,cursor,viewport) + cursor = cursor or utils.getBuildingCenter(building) + + df.global.world.selected_building = building + self:moveCursorTo(cursor, viewport) +end + function DwarfOverlay:propagateMoveKeys(keys) for code,_ in pairs(MOVEMENT_KEYS) do if keys[code] then diff --git a/library/lua/utils.lua b/library/lua/utils.lua index 009bdf98..19a4e6f6 100644 --- a/library/lua/utils.lua +++ b/library/lua/utils.lua @@ -373,6 +373,14 @@ function call_with_string(obj,methodname,...) ) end +function getBuildingName(building) + return call_with_string(building, 'getName') +end + +function getBuildingCenter(building) + return xyz2pos(building.centerx, building.centery, building.z) +end + -- Ask a yes-no question function prompt_yes_no(msg,default) local prompt = msg |
