From 2dfddee8c6fab6eb76cbfe3d95f7c30bfb870702 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 25 Sep 2026 21:53:00 -0300 Subject: sketchbook: what the game's review needed - input.started: true on the first update of a run, never after a reload, for a sketch to stop what should not resume from saved state. - A console line that errors fails its script. Sketch commands answer unknown, done or failed (abi.Outcome) instead of a bool that hid errors. - addScript also takes the hot-reloadable library, run through the generic host, so scripts can reload a real build. - Sounds that do not load are .none, not an empty clip. - sk_tag reads an enum field's tag name from the web build, for tests. --- src/sketch/root.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/sketch/root.zig') diff --git a/src/sketch/root.zig b/src/sketch/root.zig index 316a886..0567839 100644 --- a/src/sketch/root.zig +++ b/src/sketch/root.zig @@ -193,16 +193,17 @@ pub fn Glue(comptime App: type) type { else => App.draw(current, session(ss), &f), } } - pub fn command(ctx: *const abi.Context, s: [*]u8, ss: [*]u8, line: *const []const u8) callconv(.c) bool { - if (!@hasDecl(App, "command")) return false; + pub fn command(ctx: *const abi.Context, s: [*]u8, ss: [*]u8, line: *const []const u8) callconv(.c) abi.Outcome { + if (!@hasDecl(App, "command")) return .unknown; var c: Console = .{ .host = ctx.host, .in = ctx.input }; - return switch (comptime arity(App.command)) { + const taken = switch (comptime arity(App.command)) { 3 => App.command(state(s), &c, line.*), else => App.command(state(s), session(ss), &c, line.*), } catch |err| { c.print("{t}. Type help for usage.", .{err}); - return true; + return .failed; }; + return if (taken) .done else .unknown; } }; } -- cgit v1.3