Files
mandy/mods/gate_driver/main.lua
TheGeogeo 923dc26741 mods: gate_driver takes a run from the menus into the world (D3D12-GATE-DRIVER-MOD)
A Lua mod for in-game gates and A/Bs: it presses Enter through the title's menus only once frames
have moved on since the last press, shows control by holding W (the player must walk 1 to 30 m in
3 s; more is the title placing the player, which it waits out without a press), then stands still
(idle) or walks a fixed loop (roam). It logs GATE PRESS/PROBE/CONTROL/MARK/SHOT/FAIL lines with
distances only, never a position. It ships disabled; a run enables a copy with LEONIDA_MODS and
needs LEONIDA_GAME_ACTIONS=1 for the player's position.

The logic is in driver.lua and takes the calls it uses as an argument, so leonida-lua's tests run
it on a stub with a simulated clock: menus, control, roam, no position, no control, a jump.
2026-11-30 21:02:29 +01:00

31 lines
1.1 KiB
Lua

-- The gate's driver mod (docs/lua-modding.md, "The gate's driver mod"). Ships disabled: a run enables a copy of it.
-- It needs LEONIDA_GAME_ACTIONS=1 for the player's position. An optional gate.txt beside this file sets
-- `mode = idle` or `mode = roam` and any number of driver.lua's defaults (`give_up = 600`, ...), one a line.
local driver = require("driver")
local config = {}
local text = leonida.read_file("gate.txt")
if text then
for line in text:gmatch("[^\r\n]+") do
local key, value = line:match("^%s*([%w_]+)%s*=%s*(.-)%s*$")
if key == "mode" and (value == "idle" or value == "roam") then
config.mode = value
elseif key and type(driver.defaults[key]) == "number" and tonumber(value) then
config[key] = tonumber(value)
end
end
end
local d = driver.new({
time = leonida.time,
frame = leonida.frame,
position = leonida.player_position,
hold = leonida.hold_keys,
release = leonida.release_keys,
shot = leonida.screenshot,
log = leonida.log,
}, config)
leonida.log("GATE", "loaded", "mode=" .. d.cfg.mode)
leonida.on("frame", function() d:step() end)