Skip to content

Commit a262808

Browse files
committed
reinstate flashstep
1 parent 42919fb commit a262808

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

changelog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Template for new versions:
3535
- `unretire-anyone`: (reinstated) choose anybody in the world as an adventurer
3636
- `reveal-adv-map`: (reinstated) reveal (or hide) the adventure map
3737
- `resurrect-adv`: (reinstated) allow your adventurer to recover from death
38+
- `flashstep`: (reinstated) teleport your adventurer to the mouse cursor
3839

3940
## New Features
4041
- `instruments`: new subcommand ``instruments order`` for creating instrument work orders

docs/flashstep.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ flashstep
22
=========
33

44
.. dfhack-tool::
5-
:summary: Teleport your adventurer to the cursor.
6-
:tags: unavailable
5+
:summary: Teleport your adventurer to the mouse cursor.
6+
:tags: adventure armok units
77

88
``flashstep`` is a hotkey-friendly teleport that places your adventurer where
9-
your cursor is.
9+
your mouse cursor is. A small area around the target tile is revealed. If you
10+
take a step, then the normal vision cone area around the unit is revealed.
1011

1112
Usage
1213
-----

flashstep.lua

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
--Teleports adventurer to cursor
2-
--[====[
3-
4-
flashstep
5-
=========
6-
A hotkey-friendly teleport that places your adventurer where your cursor is.
7-
8-
]====]
1+
local function reveal_tile(pos)
2+
local block = dfhack.maps.getTileBlock(pos)
3+
local des = block.designation[pos.x%16][pos.y%16]
4+
des.hidden = false
5+
des.pile = true -- reveal the tile on the map
6+
end
97

10-
function flashstep()
11-
local unit = df.global.world.units.active[0]
12-
if df.global.adventure.menu ~= df.ui_advmode_menu.Look then
13-
qerror("No [l] cursor located! You kinda need it for this script.")
8+
local function flashstep()
9+
local unit = dfhack.world.getAdventurer()
10+
if not unit then return end
11+
local pos = dfhack.gui.getMousePos()
12+
if not pos then return end
13+
if dfhack.units.teleport(unit, pos) then
14+
reveal_tile(xyz2pos(pos.x-1, pos.y-1, pos.z))
15+
reveal_tile(xyz2pos(pos.x, pos.y-1, pos.z))
16+
reveal_tile(xyz2pos(pos.x+1, pos.y-1, pos.z))
17+
reveal_tile(xyz2pos(pos.x-1, pos.y, pos.z))
18+
reveal_tile(pos)
19+
reveal_tile(xyz2pos(pos.x+1, pos.y, pos.z))
20+
reveal_tile(xyz2pos(pos.x-1, pos.y+1, pos.z))
21+
reveal_tile(xyz2pos(pos.x, pos.y+1, pos.z))
22+
reveal_tile(xyz2pos(pos.x+1, pos.y+1, pos.z))
1423
end
15-
dfhack.units.teleport(unit, xyz2pos(pos2xyz(df.global.cursor)))
16-
dfhack.maps.getTileBlock(unit.pos).designation[unit.pos.x%16][unit.pos.y%16].hidden = false
1724
end
1825

1926
flashstep()

0 commit comments

Comments
 (0)