From fa3ca590594c6e12422273f3a31e073bfa72215a Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Sat, 21 Mar 2026 16:44:20 -0500 Subject: [PATCH] support loading from .zip/.love file --- conf.lua | 11 ++++++----- main.lua | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/conf.lua b/conf.lua index 478c510..a6ad7ef 100644 --- a/conf.lua +++ b/conf.lua @@ -1,7 +1,8 @@ function love.conf(t) - t.window.width = 1024 - t.window.height = 1024 - t.window.depth = true - t.window.resizable = true - t.graphics.excluderenderers = {"vulkan", "metal"} + t.identity = "love-demo2" + t.window.width = 1024 + t.window.height = 1024 + t.window.depth = true + t.window.resizable = true + t.graphics.excluderenderers = {"vulkan", "metal"} end diff --git a/main.lua b/main.lua index 421e0d3..9650c4d 100644 --- a/main.lua +++ b/main.lua @@ -34,7 +34,25 @@ void update(float time); int x3, int y3, int x4, int y4); ]] local source_path = love.filesystem.getSource() - test = ffi.load(source_path .. "/test.so") + local is_zip = source_path:sub(-#".zip") == ".zip" + local is_love = source_path:sub(-#".love") == ".love" + + if is_zip or is_love then + if love.filesystem.isFused() then + local archive = love.filesystem.getSourceBaseDirectory() + end + + local contents, size = love.filesystem.read("data", "test.so") + assert(contents ~= nil, size) + local write_success, message = love.filesystem.write("test.so", contents, size) + local app_data = love.filesystem.getAppdataDirectory() + + -- the love2d "filesystem" API is the worst possible design in the + -- entire history of computing + test = ffi.load(app_data .. "/love/love-demo2/test.so") + else + test = ffi.load("./test.so") + end test.load(source_path) end