From 9bf1d800f2a24ed71221c64370c98ee8d907314b Mon Sep 17 00:00:00 2001 From: t Date: Wed, 10 Jun 2026 09:46:00 -0600 Subject: expose `panto` to extensions as a require()able module, not a global --- src/lua_event_bridge.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lua_event_bridge.zig') diff --git a/src/lua_event_bridge.zig b/src/lua_event_bridge.zig index b445072..1fbc82a 100644 --- a/src/lua_event_bridge.zig +++ b/src/lua_event_bridge.zig @@ -720,7 +720,12 @@ fn harvestOnInto(bridge: *EventBridge) !void { } fn runScript(L: *c.lua_State, src: [:0]const u8) !void { - if (c.luaL_loadstring(L, src.ptr) != 0 or c.lua_pcallk(L, 0, 0, 0, 0, null) != 0) { + // `panto` is not a global; extensions reach it via `require('panto')`. + // Prepend the require so these bridge tests can keep using `panto.ext` + // without each script repeating the boilerplate. + var buf: [8192]u8 = undefined; + const wrapped = std.fmt.bufPrintZ(&buf, "local panto = require(\"panto\")\n{s}", .{src}) catch return error.LuaScriptFailed; + if (c.luaL_loadstring(L, wrapped.ptr) != 0 or c.lua_pcallk(L, 0, 0, 0, 0, null) != 0) { var len: usize = 0; const msg = c.lua_tolstring(L, -1, &len); std.debug.print("lua error: {s}\n", .{msg[0..len]}); -- cgit v1.3