diff options
| author | t <t@tjp.lol> | 2026-06-10 09:46:00 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-10 09:55:05 -0600 |
| commit | 9bf1d800f2a24ed71221c64370c98ee8d907314b (patch) | |
| tree | d1b77ac9140e57ba523e97a4b815475ddba2c04e /src/lua_event_bridge.zig | |
| parent | 938db5f476184b2d4f613e04cce60a5191581d7f (diff) | |
expose `panto` to extensions as a require()able module, not a global
Diffstat (limited to 'src/lua_event_bridge.zig')
| -rw-r--r-- | src/lua_event_bridge.zig | 7 |
1 files changed, 6 insertions, 1 deletions
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]}); |
