ludic/packages/ludic.tracks/read.ludic
Orkuncakilkaya bf73f7edaf feat(ludic.tracks): prints, their age and reading them as a mechanic package
A ring of prints per kind; a port for the trip's time, the reader's tier, a
bearing in words and a hook the game draws each print through. A read is a
TrackRead fact on tracks_reads() every time and a count the first time; other
sign is told with tracks_note. The count and last bearing are its save section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 04:54:43 +03:00

54 lines
1.6 KiB
Text

# read.ludic - reading the ground. A print is read once: reading it again says the same thing
# and counts nothing, so pressing a key over one print is not as good as walking a trail.
export function tracks_fresh_of(age: float) -> int {
if age > tk_recent_h { return TRACK_OLD }
if age > tk_fresh_h { return TRACK_RECENT }
return TRACK_FRESH
}
function tk_push(f: TrackRead) -> void {
if f.first { tk_read_n += 1 }
q_push(tracks_reads(), f)
}
# read the print at a slot (tracks_nearest's answer): a fact every time, a count the first time
export function tracks_read(slot: int) -> void {
if slot < 0 or tk_ring == null or slot >= len(tk_ring) { return }
let t = tk_ring[slot]
let f = new TrackRead
f.sp = t.sp
f.source = TRACK_PRINT
f.kind = slot / tk_cap
f.legend = t.legend
f.age = tracks_age(slot)
f.fresh = tracks_fresh_of(f.age)
f.yaw = t.yaw
f.named = tk_named()
f.bearing = tk_bearing(t.yaw)
f.first = not t.read
t.read = true
tracks_note_bearing(t.yaw)
tk_push(f)
}
# a sign that is not a print (droppings, a legend's mark): the caller knows whether it is the
# first reading of it
export function tracks_note(sp: int, source: int, legend: bool, yaw: float, first: bool) -> void {
let f = new TrackRead
f.sp = sp
f.source = source
f.legend = legend
f.yaw = yaw
f.named = tk_named()
f.bearing = tk_bearing(yaw)
f.first = first
tk_push(f)
}
# the way the last thing read went (a bed, droppings, a print)
export function tracks_note_bearing(yaw: float) -> void {
tk_yaw = yaw
tk_has_yaw = true
}
export function tracks_set_read_count(n: int) -> void { tk_read_n = n }