diff options
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]}); |
