Skip to content

Commit dc41b88

Browse files
committed
cmd events schema is an array (rows kind); screenshot names get .png
1 parent 781f45f commit dc41b88

5 files changed

Lines changed: 37 additions & 17 deletions

File tree

‎docs/tecs2d/debug-reference.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,7 @@ freeze on
26582658
freeze off
26592659
```
26602660

2661-
### `step [n] [dt=N] [events={}] [force] [lua=...] [per_frame=...] [quiet] [wait]` {#cmd-step}
2661+
### `step [n] [dt=N] [events=[{..}]] [force] [lua=...] [per_frame=...] [quiet] [wait]` {#cmd-step}
26622662

26632663
Tick the game forward N frames while otherwise frozen.
26642664

@@ -2670,7 +2670,7 @@ MCP tool: `cmd_step`
26702670
| --- | --- | --- |
26712671
| `n` | number | number of frames to tick (default: 1) |
26722672
| `dt` | number | seconds each stepped frame carries (default 1/fps) |
2673-
| `events` | table | input_tape rows to queue before stepping ({at, event, args}) |
2673+
| `events` | rows | input_tape rows to queue before stepping ({at, event, args}) |
26742674
| `force` | boolean | queue events even when a press is already held (tape force) |
26752675
| `lua` | string | Lua to evaluate (run_lua sandbox) after the last frame; defers the response until the step completes |
26762676
| `per_frame` | string | Lua evaluated after EACH stepped frame; return true to stop early (n is the cap). Side effects allowed. |
@@ -2755,7 +2755,7 @@ MCP tool: `cmd_input_tape`
27552755

27562756
| Argument | Type | Description |
27572757
| --- | --- | --- |
2758-
| `events` | table | array of {at = <gameplay frames from now>, event = <love event>, args = {...}} |
2758+
| `events` | rows | array of {at = <gameplay frames from now>, event = <love event>, args = {...}} |
27592759
| `clear` | boolean | drop pending rows and release anything the tape holds down |
27602760
| `force` | boolean | allow taping 'escape' |
27612761

‎docs/tecs2d/mcp/default-tools.json‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,10 @@
977977
},
978978
"events": {
979979
"description": "array of {at = <gameplay frames from now>, event = <love event>, args = {...}}",
980-
"type": "object"
980+
"items": {
981+
"type": "object"
982+
},
983+
"type": "array"
981984
},
982985
"force": {
983986
"description": "allow taping 'escape'",
@@ -2192,7 +2195,10 @@
21922195
},
21932196
"events": {
21942197
"description": "input_tape rows to queue before stepping ({at, event, args})",
2195-
"type": "object"
2198+
"items": {
2199+
"type": "object"
2200+
},
2201+
"type": "array"
21962202
},
21972203
"force": {
21982204
"description": "queue events even when a press is already held (tape force)",

‎src/tecs2d/debug/internal/cmd/capture.tl‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,11 @@ function capture.commands(d: cmdtypes.Deps): {cmdtypes.Command}
15431543
run = function(v: {string: any}, _parts: {string}): cmdtypes.Result
15441544
reg.shotCounter = reg.shotCounter + 1
15451545
local name = (v.name as string) or ("debug-shot-" .. tostring(reg.shotCounter) .. ".png")
1546+
-- The file is encoded as PNG regardless; a bare name would
1547+
-- write an extensionless file that viewers then hunt for.
1548+
if not name:lower():match("%.png$") then
1549+
name = name .. ".png"
1550+
end
15461551
local p = pipeline()
15471552
local hasArea = ctx.hasArea and p ~= nil
15481553
local ax1, ay1, ax2, ay2 = 0.0, 0.0, 0.0, 0.0

‎src/tecs2d/debug/internal/cmd/session.tl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local stepSchema <const>: cmdargs.Schema = {
2525
n = {default = 1, help = "number of frames to tick"},
2626
dt = {kind = "number",
2727
help = "seconds each stepped frame carries (default 1/fps)"},
28-
events = {kind = "table",
28+
events = {kind = "rows",
2929
help = "input_tape rows to queue before stepping ({at, event, args})"},
3030
lua = {help = "Lua to evaluate (run_lua sandbox) after the last frame; "
3131
.. "defers the response until the step completes"},
@@ -45,7 +45,7 @@ cmdargs.validate(stepSchema)
4545

4646
local inputTapeSchema <const>: cmdargs.Schema = {
4747
args = {
48-
events = {kind = "table",
48+
events = {kind = "rows",
4949
help = "array of {at = <gameplay frames from now>, event = <love event>, args = {...}}"},
5050
clear = {kind = "boolean",
5151
help = "drop pending rows and release anything the tape holds down"},

‎src/tecs2d/debug/internal/cmdargs.tl‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ local record cmdargs
2828
forward: string
2929
synthetic: {string}
3030
-- Explicit value type ("number" / "boolean" / "string" / "list" /
31-
-- "table"). When omitted it is inferred from `default`. Set it for an
32-
-- optional typed arg that has no default, e.g. a number that defaults
33-
-- to nil (leave unchanged). A "list" is a comma-separated string on
34-
-- the command line and a JSON string array over MCP; a "table" is a
35-
-- brace-balanced Lua expression on the command line and a JSON object
36-
-- over MCP (actions receive a string or a table and handle both).
31+
-- "table" / "rows"). When omitted it is inferred from `default`. Set
32+
-- it for an optional typed arg that has no default, e.g. a number
33+
-- that defaults to nil (leave unchanged). A "list" is a
34+
-- comma-separated string on the command line and a JSON string array
35+
-- over MCP; a "table" is a brace-balanced Lua expression on the
36+
-- command line and a JSON object over MCP; "rows" is the same on the
37+
-- console but a JSON ARRAY of objects over MCP (actions receive a
38+
-- string or a table and handle both).
3739
kind: string
3840
-- Allowed values for a string arg; projected as a JSON Schema enum.
3941
enum: {string}
@@ -146,7 +148,8 @@ function cmdargs.validate(schema: cmdargs.Schema)
146148
local args = schema.args
147149
for name, spec in pairs(args) do
148150
if spec.rest then
149-
if argType(spec) ~= "string" and argType(spec) ~= "table" then
151+
local at = argType(spec)
152+
if at ~= "string" and at ~= "table" and at ~= "rows" then
150153
error("cmdargs: rest arg '" .. name .. "' must be string-typed")
151154
end
152155
if isSynthetic(spec) or spec.forward then
@@ -396,12 +399,14 @@ function cmdargs.parseValues(schema: cmdargs.Schema, given: {string: any}): {str
396399
end
397400
local want = argType(spec)
398401
local got = type(v)
399-
if want == "list" or want == "table" then
402+
if want == "list" or want == "table" or want == "rows" then
400403
-- JSON arrays/objects arrive as tables; strings stay accepted
401-
-- (the comma form for lists, a Lua expression for tables).
404+
-- (the comma form for lists, a Lua expression for tables/rows).
402405
if got ~= "table" and got ~= "string" then
403406
return nil, name .. " must be a JSON " ..
404-
((want == "list") and "array" or "object") .. ", got " .. got
407+
((want == "list") and "array"
408+
or (want == "rows") and "array of objects"
409+
or "object") .. ", got " .. got
405410
end
406411
if want == "list" then
407412
if got == "string" then
@@ -477,6 +482,8 @@ function cmdargs.toolSchema(schema: cmdargs.Schema): {string: any}
477482
prop = {type = "array", items = {type = "string"}, description = desc}
478483
elseif t == "table" then
479484
prop = {type = "object", description = desc}
485+
elseif t == "rows" then
486+
prop = {type = "array", items = {type = "object"}, description = desc}
480487
else
481488
prop = {type = t, description = desc}
482489
end
@@ -546,6 +553,8 @@ function cmdargs.signature(schema: cmdargs.Schema): string
546553
hint = "a,b"
547554
elseif kind == "table" then
548555
hint = "{}"
556+
elseif kind == "rows" then
557+
hint = "[{..}]"
549558
else
550559
hint = "..."
551560
end

0 commit comments

Comments
 (0)