utils.readTextFile = function (path)
local f = assert(io.open(path, "rb"))
local content = f:read("*all")
f:close()
return content
end
and this works when I run the game in "dev" mode, but it fails when I try to run the game after I packed it inside the AppImage file (following the wiki instructions). This makes sense to me somehow but, what would be the right way to fix it? I see love.filesystem has a bunch of useful methods to get paths, but Idk if something will work for my case.
This is the error I get, and it makes sense since (I guess) it's looking for the assets folder at the same level as the AppImage file is?
Last edited by alberto_lara on Tue Nov 08, 2022 4:43 pm, edited 1 time in total.
At a quick glance, I found this post by zorg about io.* library's shortcomings, and I imagine you're experiencing some of these issues using io.open can bring about in a packed game. Essentially, it might be looking at a wrong place (if the filepath is otherwise correct), and as such doesn't find the file you're looking for. Might be better if you just use love.filesystem.read instead.
I tried to use some of io.* functions in the past, and I couldn't get them to comfortably work with love2d for my purposes.
For some reason I thought love.filesystem was only for those user directories outside of the game code, but it can also be used to read/write inside your own game root directory, right? if so, yeah, maybe I'm just using IO carelessly
love.filesystem (in 11.4 and earlier) is sandboxed, yes, but to both where your main.lua is (whether zipped or not), and also to your project's save directory.
You can still get around that limitation in certain ways though (ffi, or using libraries that already do that for you, like nativefs or my own love-fml; both does different things), but for most purposes, those two places are enough.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.