Skip to content

Commit

Permalink
Requested changes
Browse files Browse the repository at this point in the history
* Update position.lua
* Update position.rst
* Update changelog.txt
  • Loading branch information
Bumber64 authored Sep 5, 2024
1 parent 9e4b683 commit fc7efa3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Template for new versions:
- `gui/sitemap`: show whether a unit is friendly, hostile, or wild
- `gui/sitemap`: show whether a unit is caged
- `gui/control-panel`: include option for turning off dumping of old clothes for `tailor`, for players who have magma pit dumps and want to save old clothes from being dumped into the magma
- `position`: report current historical era (e.g., "Age of Myth") and site/adventurer world coords
- `position`: report current historical era (e.g., "Age of Myth"), site/adventurer world coords, and mouse map tile coords

## Documentation
- `gui/embark-anywhere`: add information about how the game determines world tile pathability and instructions for bridging two landmasses
Expand Down
4 changes: 2 additions & 2 deletions docs/position.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ position
This tool reports the current date, clock time, month, season, and historical
era. It also reports the keyboard cursor position (or just the z-level if no
active cursor), window size, and mouse location on the screen. If a site is
loaded, it prints the world coordinates of the site, else the world
coordinates of the adventurer.
loaded, it prints the world coordinates of the site. If not, it prints the world
coordinates of the adventurer (if applicable).

Can also be used to copy the current keyboard cursor position for later use.

Expand Down
36 changes: 24 additions & 12 deletions position.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,43 @@ end

print('Place:')
print(' The z-level is z='..df.global.window_z)
print(' The cursor is at x='..cursor.x..', y='..cursor.y)
print(' The window is '..df.global.gps.dimx..' tiles wide and '..df.global.gps.dimy..' tiles high.')

if df.global.gps.mouse_x < 0 then
print(' The mouse is not in the DF window.')
if cursor.x < 0 then
print(' The keyboard cursor is inactive.')
else
print(' The mouse is at x='..df.global.gps.mouse_x..', y='..df.global.gps.mouse_y..' within the window.')
print(' The keyboard cursor is at x='..cursor.x..', y='..cursor.y)
end

local x, y = dfhack.screen.getWindowSize()
print(' The window is '..x..' tiles wide and '..y..' tiles high.')

x, y = dfhack.screen.getMousePos()
if x then
print(' The mouse is at x='..x..', y='..y..' within the window.')
local pos = dfhack.gui.getMousePos()
if pos then
print(' The mouse is over map tile x='..pos.x..', y='..pos.y)
end
else
print(' The mouse is not in the DF window.')
end

local wd = df.global.world.world_data
local site = dfhack.world.getCurrentSite()
if site then
print((' The current site is at x=%d, y=%d on the world map (%dx%d).'):
print((' The current site is at x=%d, y=%d on the %dx%d world map.'):
format(site.pos.x, site.pos.y, wd.world_width, wd.world_height))
elseif dfhack.world.isAdventureMode() then
local ax, ay = -1, -1
x, y = -1, -1
for _,army in ipairs(df.global.world.armies.all) do
if army.flags.player then
ax, ay = army.pos.x // 48, army.pos.y // 48
x, y = army.pos.x // 48, army.pos.y // 48
break
end
end
if ax < 0 then
ax, ay = wd.midmap_data.adv_region_x, wd.midmap_data.adv_region_y
if x < 0 then
x, y = wd.midmap_data.adv_region_x, wd.midmap_data.adv_region_y
end
print((' The adventurer is at x=%d, y=%d on the world map (%dx%d).'):
format(ax, ay, wd.world_width, wd.world_height))
print((' The adventurer is at x=%d, y=%d on the %dx%d world map.'):
format(x, y, wd.world_width, wd.world_height))
end

0 comments on commit fc7efa3

Please sign in to comment.