From b6daeaa328ad339d28a9c869506f7593134dfbf7 Mon Sep 17 00:00:00 2001 From: ArthurErlich Date: Mon, 5 Oct 2026 22:17:52 +0200 Subject: [PATCH] chore(prototype): log lane layout of shared street segments Co-Authored-By: Claude Opus 5.5 --- mod/content/overtake_probe.script.tl | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mod/content/overtake_probe.script.tl b/mod/content/overtake_probe.script.tl index caef036..a2b02d0 100644 --- a/mod/content/overtake_probe.script.tl +++ b/mod/content/overtake_probe.script.tl @@ -25,6 +25,34 @@ local function turnaround(edge : EdgeId) : integer return tn.turnaroundEdges[edge.index + 1] end +local function modes(m : {TransportMode : boolean}) : string + local out : {string} = {} + for k, v in pairs(m or {}) do + if v then table.insert(out, tostring(k)) end + end + return table.concat(out, ",") +end + +-- per street segment: BaseEdge lane layout + TransportNetwork lanes (modes, speed, opposite lane) +local function segmentInfo(seg : integer) : string + local be = api.engine.getComponent(seg, api.type.ComponentType.BASE_EDGE) as Engine.Component.BaseEdge + local tn = api.engine.getComponent(seg, api.type.ComponentType.TRANSPORT_NETWORK) as Engine.Component.TransportNetwork + local parts : {string} = {} + if be ~= nil then + table.insert(parts, string.format("roadType=%s template=%s laneConfigs=%d", tostring(be.roadType), tostring(be.roadTemplate), #be.laneConfigs)) + for i, lc in ipairs(be.laneConfigs) do + table.insert(parts, string.format(" lc%d fwd=%s off=%.1f w=%.1f modes=[%s]", i, tostring(lc.forward), lc.offset, lc.width, modes(lc.transportModes))) + end + end + if tn ~= nil then + table.insert(parts, string.format("tnEdges=%d", #tn.edges)) + for i, e in ipairs(tn.edges) do + table.insert(parts, string.format(" tn%d modes=[%s] speedLimit=%.1f curSpeed=%.1f turnaround=%s", i - 1, modes(e.transportModes), e.speedLimit, e.curSpeed, tostring(tn.turnaroundEdges[i]))) + end + end + return table.concat(parts, "\n" .. TAG .. " ") +end + local function dump(dt : number) local player = api.engine.util.getPlayer() local vehicles = api.engine.getEntitiesWithComponent(api.type.ComponentType.TRANSPORT_VEHICLE, { requireOwnedByPlayer = player }) @@ -53,6 +81,7 @@ local function dump(dt : number) for seg, list in pairs(bySegment) do if #list > 1 then p(string.format("SHARED seg=%d: %s", seg, table.concat(list, " "))) + p(" SEGMENT " .. seg .. " " .. segmentInfo(seg)) end end end