Page 1 of 1

love.filesystem.mount() not working

Posted: Fri Oct 18, 2019 4:14 pm
by DemonExposer
Hi, I was just trying to display an image located outside of the .love file. The image is located in the same directory the .love file is in. In the wiki, it said something like the code below, is a way of displaying the image. Actually the exact way of displaying image is not important here, it's all about the variables "dir" and "success". The variable "success" is not true, and I don't understand why. There is a directory called "hai" in the .love file, so it should mount. Some help would be greatly appreciated!

Code: Select all

function love.update(dt)
	dir = love.filesystem.getSourceBaseDirectory()
	success = love.filesystem.mount(dir, "hai")
	if success then
		img = love.graphics.newImage("hai/aladeen.jpeg")
	else
		pageText = "nope"
	end
end

Re: love.filesystem.mount() not working

Posted: Fri Oct 18, 2019 11:14 pm
by zorg
Hi and welcome to the forums.

>in the love file
That there is your issue; if the image is in a directory in the löve file, you just do img = love.graphics.newImage("hai/aladeen.jpeg"), because everything in the löve file is already mounted.
If the hai directory was next to the löve file, outside of it, then would you need to mount the source-base directory.

Re: love.filesystem.mount() not working

Posted: Tue Oct 22, 2019 7:48 pm
by DemonExposer
zorg wrote: Fri Oct 18, 2019 11:14 pm Hi and welcome to the forums.

>in the love file
That there is your issue; if the image is in a directory in the löve file, you just do img = love.graphics.newImage("hai/aladeen.jpeg"), because everything in the löve file is already mounted.
If the hai directory was next to the löve file, outside of it, then would you need to mount the source-base directory.
As I believe I specified, I'm trying to mount the sourceBaseDirectory TO the "hai" directory, I'm not trying to mount the "hai" directory. In the code, it says

Code: Select all

success = love.filesystem.mount(dir, "hai")
This should mount whatever is in the variable dir to the directory "hai". However, The variable success is false, meaning that it did not work. I would appreciate some more help.

Re: love.filesystem.mount() not working

Posted: Wed Oct 23, 2019 5:35 am
by raidho36
Mounting base directory is only possible if the game is fused. This is stated in the manual.

Re: love.filesystem.mount() not working

Posted: Wed Oct 23, 2019 10:26 am
by zorg
I think there indeed was a miscommunication then; you do not need to have any directories inside the löve file to be able to mount into, since the actual filesystem hierarchy (including the inside of your zip file renamed to .love) and löve's virtual filesystem that it uses internally (through a library called PhysFS) are completely separate. (Case in point, both the folder/.love file with main.lua in it, and your project's save folder, two separate places regarding the actual filesystem, is mounted to the same place, the virtual filesystem's root, as far as löve is concerned)

But again, the issue wasn't whether you had or had not had a "hai" directory in your .love file, the issue is you trying to mount the SourceBase directory when the game's not fused as raidho said. The wiki tells you how you can fuse it.

(the mount function in löve, apart from the above side-implementation, is really only usable to mount zip archives from either where your main.lua is, or from directories starting from that path; or from your project's save folder; since the function does not allow mounting any other arbitrary path)

...There are ways around this though, but i wouldn't recommend them for games, only if one's making non-game applications.

Re: love.filesystem.mount() not working

Posted: Thu Oct 24, 2019 2:13 pm
by DemonExposer
zorg wrote: Wed Oct 23, 2019 10:26 am I think there indeed was a miscommunication then; you do not need to have any directories inside the löve file to be able to mount into, since the actual filesystem hierarchy (including the inside of your zip file renamed to .love) and löve's virtual filesystem that it uses internally (through a library called PhysFS) are completely separate. (Case in point, both the folder/.love file with main.lua in it, and your project's save folder, two separate places regarding the actual filesystem, is mounted to the same place, the virtual filesystem's root, as far as löve is concerned)

But again, the issue wasn't whether you had or had not had a "hai" directory in your .love file, the issue is you trying to mount the SourceBase directory when the game's not fused as raidho said. The wiki tells you how you can fuse it.

(the mount function in löve, apart from the above side-implementation, is really only usable to mount zip archives from either where your main.lua is, or from directories starting from that path; or from your project's save folder; since the function does not allow mounting any other arbitrary path)

...There are ways around this though, but i wouldn't recommend them for games, only if one's making non-game applications.
thank you very much for the explanation!