love.filesystem.mount() not working

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
DemonExposer
Prole
Posts: 3
Joined: Fri Oct 18, 2019 3:58 pm

love.filesystem.mount() not working

Post by DemonExposer » Fri Oct 18, 2019 4:14 pm

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

User avatar
zorg
Party member
Posts: 2735
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: love.filesystem.mount() not working

Post by zorg » 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.
Me and my stuff :3True 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.

DemonExposer
Prole
Posts: 3
Joined: Fri Oct 18, 2019 3:58 pm

Re: love.filesystem.mount() not working

Post by DemonExposer » Tue Oct 22, 2019 7:48 pm

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.

User avatar
raidho36
Party member
Posts: 1954
Joined: Mon Jun 17, 2013 12:00 pm

Re: love.filesystem.mount() not working

Post by raidho36 » Wed Oct 23, 2019 5:35 am

Mounting base directory is only possible if the game is fused. This is stated in the manual.

User avatar
zorg
Party member
Posts: 2735
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: love.filesystem.mount() not working

Post by zorg » 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.
Me and my stuff :3True 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.

DemonExposer
Prole
Posts: 3
Joined: Fri Oct 18, 2019 3:58 pm

Re: love.filesystem.mount() not working

Post by DemonExposer » Thu Oct 24, 2019 2:13 pm

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests