clean up lua stuff a bit and add mez.inspect

This commit is contained in:
Squibid 2025-12-10 21:03:03 -05:00
parent 1f2e333846
commit ec8b86cbb7
Signed by: squibid
GPG key ID: BECE5684D3C4005D
6 changed files with 698 additions and 309 deletions

View file

@ -1,25 +1,25 @@
const Bridge = @This();
const std = @import("std");
const Lua = @import("Lua.zig");
const zlua = @import("zlua");
const gpa = std.heap.c_allocator;
pub fn getNestedField(L: *Lua, path: []u8) bool {
pub fn getNestedField(L: *zlua.Lua, path: []u8) bool {
var tokens = std.mem.tokenizeScalar(u8, path, '.');
var first = true;
while (tokens.next()) |token| {
const tok = gpa.dupeZ(u8, token) catch return false;
if (first) {
_ = L.state.getGlobal(tok) catch return false;
_ = L.getGlobal(tok) catch return false;
first = false;
} else {
_ = L.state.getField(-1, tok);
L.state.remove(-2);
_ = L.getField(-1, tok);
L.remove(-2);
}
if (L.state.isNil(-1)) {
if (L.isNil(-1)) {
return false;
}
}