|
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 |
9 | 7 |
|
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)) |
14 | 23 | 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 |
17 | 24 | end
|
18 | 25 |
|
19 | 26 | flashstep()
|
0 commit comments