diff --git a/d3d12/crates/leonida-lua/src/tests.rs b/d3d12/crates/leonida-lua/src/tests.rs index 12147af11..62884f5e5 100644 --- a/d3d12/crates/leonida-lua/src/tests.rs +++ b/d3d12/crates/leonida-lua/src/tests.rs @@ -1168,6 +1168,14 @@ fn the_gate_driver_fails_without_a_position_or_without_control() { log.iter().any(|l| l.starts_with("GATE FAIL no control")), "{log:?}" ); + // A probe that shows no move asks for a press at the menus' pace, not right away: one every 25 s. + let presses: Vec = log + .iter() + .filter(|l| l.starts_with("GATE PRESS")) + .map(|l| seconds_of(l)) + .collect(); + assert!(presses.len() <= 9, "{log:?}"); + assert!(presses.windows(2).all(|w| w[1] - w[0] >= 24.9), "{log:?}"); } #[test] diff --git a/docs/lua-modding.md b/docs/lua-modding.md index a3c82890e..6dbfc92bb 100644 --- a/docs/lua-modding.md +++ b/docs/lua-modding.md @@ -198,7 +198,10 @@ ships disabled: a run enables a copy of it in a mods folder of its own (`LEONIDA position is known. A start that takes minutes to compile pipelines does not throw its presses away. - **Control.** Holding W for 3 s must move the player at least 1 m and at most 30 m. More is the title placing the player itself (a load, a cutscene), not a walk: it tries again (`GATE PROBE ... placed`). Less is a screen that - still waits: it presses once more (`GATE PROBE ... still`) and tries again. + still waits (`GATE PROBE ... still`): it presses once more, at the menus' pace, and tries again. +- **Limits.** In `idle`, a mark at 0.0 m does not tell a player standing still from one the title holds (a cutscene + can start after control and hold the player); `roam` shows it. With a cold pipeline cache the world can take + minutes, and the player can stay held: `GATE CONTROL` then comes late, or `GATE FAIL no control` at 900 s. - **Then.** `idle` (the default) stands still, for measuring. `roam` walks a fixed loop: W, with short J and L turns (the stand-in pad's right stick turns the camera). - **Its log lines.** Through `leonida.log`, the log is also its heartbeat: diff --git a/mods/gate_driver/driver.lua b/mods/gate_driver/driver.lua index 8b416af60..f15420cb5 100644 --- a/mods/gate_driver/driver.lua +++ b/mods/gate_driver/driver.lua @@ -75,11 +75,14 @@ function M:step() if self.state == "boot" then if frame >= self.cfg.boot_frames and now >= self.cfg.boot_seconds then self.state = "menus" end elseif self.state == "menus" then - if self:position() then - self.state = "probe" - elseif not self.release_at and (self.press_frame == nil or frame >= self.press_frame + 3) - and (self.last_press == nil or now - self.last_press >= self.cfg.press_every) then + local may_press = not self.release_at and (self.press_frame == nil or frame >= self.press_frame + 3) + and (self.last_press == nil or now - self.last_press >= self.cfg.press_every) + if self:position() and not self.want_press then + -- Once Enter is up: a probe holding W would cut its press short. + if not self.release_at then self.state = "probe" end + elseif may_press then self:press(now, frame) + self.want_press = false end elseif self.state == "probe" then if not self.probe then @@ -107,10 +110,10 @@ function M:step() -- The title placed the player itself (a load, a cutscene): no screen to press through, show control again. self:say("PROBE", string.format("t=%.1f", now), string.format("moved=%.1f", moved), "placed") else - -- A screen still wants a press: one, then show control again. + -- A screen may still want a press: one, at the menus' pace (press_every, frames moving on), then show + -- control again. self:say("PROBE", string.format("t=%.1f", now), string.format("moved=%.1f", moved), "still") - self.state = "menus" - self:press(now, frame) + self.state, self.want_press = "menus", true end else if self.state == "roam" and (self.roam_until == nil or now >= self.roam_until) then