we're now loading a config file!

This commit is contained in:
Squibid 2025-10-22 14:23:30 -04:00
parent 86a01bbcf2
commit 9e55195f8d
Signed by: squibid
GPG key ID: BECE5684D3C4005D
6 changed files with 112 additions and 45 deletions

28
src/lua/bridge.zig Normal file
View file

@ -0,0 +1,28 @@
const Bridge = @This();
const std = @import("std");
const Lua = @import("lua.zig");
const gpa = std.heap.c_allocator;
pub fn getNestedField(L: *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;
first = false;
} else {
_ = L.state.getField(-1, tok);
L.state.remove(-2);
}
if (L.state.isNil(-1)) {
return false;
}
}
return true;
}