Skip to content

Commit 31cbc98

Browse files
committed
make lua work again
1 parent 4ca2c9d commit 31cbc98

10 files changed

Lines changed: 20 additions & 30 deletions

File tree

build.zig.zon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
.url = "git+https://github.com/natecraddock/ziglua#891945ef9c2bffcd06050c4836d414428ed7d95a",
1616
.hash = "zlua-0.1.0-hGRpC2rgBACFhBjc9s9dGN37ZaTu7rNVZZqduwitv4O7",
1717
},
18-
// // needed because Lua is a lazy dependency inside of ziglua
19-
// .lua54 = .{
20-
// .url = "https://www.lua.org/ftp/lua-5.4.6.tar.gz",
21-
// .hash = "1220f93ada1fa077ab096bf88a5b159ad421dbf6a478edec78ddb186d0c21d3476d9",
22-
// },
2318
.sokol = .{
2419
.url = "git+https://github.com/floooh/sokol-zig.git#d8c1205a4dd9ad28da411f998102ce520cdef6bc",
2520
.hash = "sokol-0.1.0-pb1HK5mGLABB7_Vt66xb8nbn8sJN_ULvd4v0wg8WypJ_",

src/framework/api/assets.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const std = @import("std");
22
const math = std.math;
3-
const ziglua = @import("ziglua");
3+
const zlua = @import("zlua");
44
const debug = @import("../debug.zig");
55
const images = @import("../images.zig");
66
const graphics = @import("../platform/graphics.zig");

src/framework/api/display.zig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
const std = @import("std");
22
const fmt = @import("fmt");
3-
const ziglua = @import("ziglua");
3+
const zlua = @import("zlua");
44
const debug = @import("../debug.zig");
55

66
var enable_debug_logging = false;
77

8-
pub var test_me: bool = true;
9-
108
pub fn set_resolution(res_x: i32, res_y: i32) void {
119
// var scale_x: f32 = 1.0;
1210
// var scale_y: f32 = 1.0;
1311

14-
debug.log("set resolution: {d}x{d}", .{res_x, res_y});
12+
debug.log("set resolution: {d}x{d}", .{ res_x, res_y });
1513
// _ = sdl.SDL_RenderGetScale(zigsdl.getRenderer(), &scale_x, &scale_y);
1614

1715
// res_x *= @intFromFloat(scale_x);
@@ -39,5 +37,5 @@ pub fn set_resolution(res_x: i32, res_y: i32) void {
3937
// }
4038

4139
pub fn set_size(one: i32, two: i32) void {
42-
debug.log("Set size: {d}x{d}", .{one, two});
40+
debug.log("Set size: {d}x{d}", .{ one, two });
4341
}

src/framework/api/draw.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const ziglua = @import("ziglua");
2+
const zlua = @import("zlua");
33
const app = @import("../app.zig");
44
const papp = @import("../platform/app.zig");
55
const debug = @import("../debug.zig");

src/framework/api/graphics.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const std = @import("std");
22
const math = @import("../math.zig");
3-
const ziglua = @import("ziglua");
3+
const zlua = @import("zlua");
44
const papp = @import("../platform/app.zig");
55
const debug = @import("../debug.zig");
66
const colors = @import("../colors.zig");

src/framework/api/keyboard.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const std = @import("std");
22
const debug = @import("../debug.zig");
3-
const ziglua = @import("ziglua");
3+
const zlua = @import("zlua");
44
const input = @import("../platform/input.zig");
55

66
pub fn key(key_idx: usize) bool {
7-
return input.isKeyPressed(@enumFromInt(key_idx));
7+
return input.isKeyPressed(@enumFromInt(key_idx));
88
}

src/framework/api/mouse.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const std = @import("std");
2-
const ziglua = @import("ziglua");
2+
const zlua = @import("zlua");
33
const input = @import("../platform/input.zig");
44
const Tuple = std.meta.Tuple;
55

66
// Get Mouse Position
7-
pub fn position() Tuple(&.{f32, f32}) {
7+
pub fn position() Tuple(&.{ f32, f32 }) {
88
const mouse_pos = input.getMousePosition();
99
return .{ mouse_pos.x, mouse_pos.y };
1010
}

src/framework/api/text.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const std = @import("std");
22
const math = std.math;
3-
const ziglua = @import("ziglua");
3+
const zlua = @import("zlua");
44
const app = @import("../app.zig");
55
const colors = @import("../colors.zig");
66
const images = @import("../images.zig");

src/framework/scripting/lua.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn runLine(lua_string: [:0]const u8) !void {
8282
};
8383
}
8484

85-
pub fn openModule(comptime name: [:0]const u8, comptime open_func: zlua.ZigFn) void {
85+
pub fn openModule(comptime name: [:0]const u8, comptime open_func: anytype) void {
8686
lua.requireF(name, zlua.wrap(open_func), true);
8787
debug.log("Lua: registered module '{s}'", .{name});
8888
}

src/framework/scripting/manager.zig

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ pub fn init() !void {
1616
// Start lua
1717
try lua_util.init();
1818

19-
// TODO fix this
2019
// Bind all the libraries using some meta programming magic at compile time
21-
// try bindZigLibrary("assets", @import("../api/assets.zig"));
22-
// try bindZigLibrary("display", @import("../api/display.zig"));
23-
// try bindZigLibrary("draw", @import("../api/draw.zig"));
24-
// try bindZigLibrary("text", @import("../api/text.zig"));
25-
// try bindZigLibrary("graphics", @import("../api/graphics.zig"));
26-
// try bindZigLibrary("input.mouse", @import("../api/mouse.zig"));
27-
// try bindZigLibrary("input.keyboard", @import("../api/keyboard.zig"));
20+
try bindZigLibrary("assets", @import("../api/assets.zig"));
21+
try bindZigLibrary("display", @import("../api/display.zig"));
22+
try bindZigLibrary("draw", @import("../api/draw.zig"));
23+
try bindZigLibrary("text", @import("../api/text.zig"));
24+
try bindZigLibrary("graphics", @import("../api/graphics.zig"));
25+
try bindZigLibrary("input.mouse", @import("../api/mouse.zig"));
26+
try bindZigLibrary("input.keyboard", @import("../api/keyboard.zig"));
2827
}
2928

3029
pub fn deinit() void {
@@ -45,10 +44,8 @@ fn isModuleFunction(comptime name: [:0]const u8, comptime in_type: anytype) bool
4544

4645
fn findLibraryFunctions(comptime module: anytype) []const ScriptFn {
4746
comptime {
48-
const info = @typeInfo(module);
4947
// Get all the public declarations in this module
50-
const decls = info.@"struct".decls;
51-
@compileLog(@typeName(@TypeOf(module)));
48+
const decls = @typeInfo(module).@"struct".decls;
5249
// filter out only the public functions
5350
var gen_fields: []const std.builtin.Type.Declaration = &[_]std.builtin.Type.Declaration{};
5451
for (decls) |d| {

0 commit comments

Comments
 (0)