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>
This commit is contained in:
parent
093ca0d260
commit
bf73f7edaf
10 changed files with 487 additions and 0 deletions
37
packages/ludic.tracks/leave.ludic
Normal file
37
packages/ludic.tracks/leave.ludic
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# leave.ludic - a print put down. Each kind is a ring: past its cap the oldest is written over, and
|
||||
# a slot written over is a new print, unread
|
||||
function tk_ok(kind: int) -> bool { return tk_ring != null and kind >= 0 and kind < tk_kinds }
|
||||
|
||||
# a print made at `made` game hours (another machine's, arriving here); the ring index, or -1
|
||||
export function tracks_leave_at(kind: int, x: float, z: float, yaw: float, sp: int, legend: bool, made: float) -> int {
|
||||
if not tk_ok(kind) { return -1 }
|
||||
var i = tk_next[kind]
|
||||
if tk_count[kind] < tk_cap {
|
||||
i = tk_count[kind]
|
||||
tk_count[kind] = tk_count[kind] + 1
|
||||
}
|
||||
tk_next[kind] = (i + 1) % tk_cap
|
||||
let t = tk_ring[kind * tk_cap + i]
|
||||
t.x = x
|
||||
t.z = z
|
||||
t.yaw = yaw
|
||||
t.sp = sp
|
||||
t.legend = legend
|
||||
t.made = made
|
||||
t.read = false
|
||||
if tk_world != null and tk_world.placed != null { tk_world.placed(kind, i) }
|
||||
return i
|
||||
}
|
||||
|
||||
export function tracks_leave(kind: int, x: float, z: float, yaw: float, sp: int, legend: bool) -> int {
|
||||
return tracks_leave_at(kind, x, z, yaw, sp, legend, tk_now())
|
||||
}
|
||||
|
||||
# the ground forgets every print (a new world)
|
||||
export function tracks_clear() -> void {
|
||||
if tk_ring == null { return }
|
||||
for k in 0 .. tk_kinds {
|
||||
tk_count[k] = 0
|
||||
tk_next[k] = 0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue