const std = @import("std");
const LuaInterop = @import("Lua/Interop.zig");
const Fs = @import("Mistox/IO.zig");

const Publish = false;
pub fn main() !void {

    // Create the allocator
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const allocator = gpa.allocator();
    defer _ = gpa.deinit();
    
    // Initilize the lua runtime
    try LuaInterop.Init(allocator);
    defer LuaInterop.DeInit();

    // Work on a method to auto detect all lua files
    var filePath: []const u8 = undefined;
    if (Publish){
        // Get the file path offset from the executable
        filePath = try Fs.GetFilePathRelative(allocator, "/../../../src/main.lua");
        defer allocator.free(filePath);

        std.debug.print( "File Location To Load : {s}\n\n", .{filePath} );
    }else{
        // Use debug for now - I can remove this later
        filePath = "/home/derek/Desktop/MistoxEngine/src/main.lua";
    }

    // Open the file and read all the content
    const FileContent = try Fs.FileRead(allocator, filePath);
    defer allocator.free(FileContent);

    // Load lua files
    try LuaInterop.LuaRuntime.doString( @ptrCast( FileContent ) );
}


// 18004566004 - Auto insurance quote fix