orientation: the travel map, unexplored ways, the nearest exit

Prompted by "do sighted players have a minimap we don't have access to?"
No widget, but two map surfaces were only half exposed: the world map
screen, and the level view itself, which IS the explored-floor map --
rememberedFoV keeps everything ever seen drawn, and a sighted player pans
over it and reads the fog edge at a glance.

The world map dropped the three things the picture carries: what kind of
place each area is (the icon shape), which way it lies, and how long
travelling there takes. The last is the number the decision turns on and
was only ever in the side panel. states/worldmap.lua is now a read() plus
details() rather than probe/render -- necessarily, because render() gets
no state table and the travel time needs the screen's currentAreaId, an
upvalue like options and selectedOption. Travel time is the game's own
getDistanceMessage, the same call the screen makes. The blurb runs to
several sentences, so it goes on = and the settle timer instead of the
focus line.

Two gotchas: options[i].icon is already an image object, so the icon id
string has to come off the model area; and describe.direction only tests
the sign of each delta, which on the map's floating-point coordinates
called almost everything diagonal, hence a 25% deadzone carrying the same
4/3 x-correction the game's own distance maths uses.

New frontier.lua answers "where haven't I been", which nothing did:
surroundings is local, examine is one tile, and the tracker only finds
things it already knows about. A frontier tile is seen, not blocking
movement, with an in-bounds unseen CARDINAL neighbour -- cardinal because
the diagonal test fires on the unseen tile behind every wall corner, so a
lit corridor would report an unexplored way per corner. Clustered
8-connected and reduced to each cluster's nearest member, so a wide
doorway is one way but two openings that both lie north stay two. Reads
only FoV/rememberedFoV and reports only THAT an opening exists, never
what is beyond it -- exactly what the fog edge shows.

Shift+End names the nearest exit without disturbing the tracker
selection. Note for later: level.exits does not exist at runtime, it is
packed as nil and never assigned. The primitive is the game's own
getListByTag("exit"), which already gates on FoV or rememberedFoV, skips
hidden tiles and sorts by distance. Exits were already a tracker
category, so this is a shortcut rather than a new capability.

"remembered" moves from verbose to normal verbosity. tileFacts reads
actors only when a tile is currently VISIBLE, so a remembered tile is
silent about whatever may be standing on it now, and at normal verbosity
that silence was indistinguishable from "nothing there". A safety flag,
not a nicety.

Also adds descriptor.probeNames: a read() descriptor has no probe table,
so menus.selfTest could only report "custom read()" and the version-bump
canary was lost on exactly the screens reaching for the most upvalues.
worldmap and research now declare their game locals and get the same
PROBE BROKEN check.

120 testbed checks, 0 failures. It caught two things review had not. The
world map said "You are currently here." twice, because
getDistanceMessage and getLastVisitedMessage return the same sentence for
the area you are standing in -- fine as two panels on screen, a stutter
in one utterance. And the first frontier check walked a step east and
demanded the numbers change; it failed on a run where nothing was wrong,
the step landing but both openings keeping the same Chebyshev distance.
Replaced with the deterministic property: every reported distance must
equal Chebyshev from the player's current position, nearest first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Accessibility Mod
2026-08-03 16:05:15 +02:00
co-authored by Claude Opus 5
parent ce0f375a10
commit 5778e86e8e
10 changed files with 1004 additions and 23 deletions
+92
View File
@@ -7,6 +7,7 @@
-- Shift+PageUp / Shift+PageDown instance that specific rat
-- Home announce distance + direction
-- Ctrl+Home walk there (what a left click does)
-- Shift+End nearest known exit, without touching the above
--
-- Two hard rules:
--
@@ -443,6 +444,95 @@ function tracker.announceLocation()
speech.say(table.concat(parts, ", "), true)
end
--------------------------------------------------------------------------------
-- Nearest exit
--------------------------------------------------------------------------------
--
-- Exits are already a tracker category, but reaching them costs several keypresses
-- of category cycling and clobbers whatever you were tracking. "Where is the way
-- out" is asked often enough, and under enough pressure, to deserve one key that
-- answers without disturbing the selection.
--
-- This does NOT use the tracker's own scan. The game has the exact primitive
-- already: level.getListByTag("exit") (modules/level.lua:1382) walks the grid,
-- gates on FoV or rememberedFoV, skips hidden tiles and returns the results
-- sorted by distance to the player. Reusing it means the FoV rule is enforced by
-- vanilla rather than restated here.
--
-- Note for anyone tempted by level.exits: it does not exist at runtime. It is
-- packed as nil (modules/level.lua:416) and never assigned; `exits` is a
-- generator parameter that gets baked into individual tiles.
local exitTemplates
local function getExitTemplates()
if exitTemplates then
return exitTemplates
end
local ok, templatesByTag = pcall(require, "modules.tile.templatesByTag")
exitTemplates = (ok and templatesByTag and templatesByTag.exit) or {}
return exitTemplates
end
-- getListByTag returns bare {x, y}, so the name has to come back off the stack.
local function exitNameAt(level, x, y)
local stack = level.grid and level.grid[x] and level.grid[x][y]
if type(stack) ~= "table" then
return "exit"
end
local templates = getExitTemplates()
for i = #stack, 1, -1 do
local tile = stack[i]
if tile and not tile.isHidden and templates[tile.templateId] then
return categories.tileName(tile)
end
end
return "exit"
end
-- Shift+End: the nearest way off this level.
function tracker.announceNearestExit()
local level = getLevel()
local actor = level and level.playerActor
if not level or not actor then
speech.say("No exits known", true)
return
end
local ok, list = pcall(level.getListByTag, "exit")
if not ok or type(list) ~= "table" or not list[1] then
speech.say("No exits known", true)
return
end
local nearest = list[1]
local parts = {
string.format("%s, %s", exitNameAt(level, nearest.x, nearest.y),
describe.offset(nearest.x - actor.x, nearest.y - actor.y)),
}
-- Same reasoning as announceLocation: straight-line offset is misleading
-- indoors, and the path count truncates to one step while threatened.
local okPath, path = pcall(level.calculatePathFromPlayer, nearest.x, nearest.y)
if okPath and path and #path > 0 then
parts[#parts + 1] = #path .. (#path == 1 and " step by path" or " steps by path")
elseif okPath then
parts[#parts + 1] = "no path"
end
if #list > 1 then
parts[#parts + 1] = #list .. " known"
end
speech.say(table.concat(parts, ", "), true)
end
-- Ctrl+Home: actually go there.
--
-- This is the keyboard equivalent of a left click on the tile (states/ingame.lua
@@ -557,6 +647,8 @@ function tracker.registerKeys(hotkeys)
hotkeys.bind("home", nil, tracker.announceLocation)
hotkeys.bind("home", "ctrl", tracker.walkToSelection)
hotkeys.bind("end", "shift", tracker.announceNearestExit)
end
return tracker