support loading from .zip/.love file

This commit is contained in:
Zack Buhman 2026-03-21 16:44:20 -05:00
parent d88cb808ff
commit fa3ca59059
2 changed files with 25 additions and 6 deletions

View File

@ -1,4 +1,5 @@
function love.conf(t) function love.conf(t)
t.identity = "love-demo2"
t.window.width = 1024 t.window.width = 1024
t.window.height = 1024 t.window.height = 1024
t.window.depth = true t.window.depth = true

View File

@ -34,7 +34,25 @@ void update(float time);
int x3, int y3, int x4, int y4); int x3, int y3, int x4, int y4);
]] ]]
local source_path = love.filesystem.getSource() 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) test.load(source_path)
end end