io.open() question
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 11
- Joined: Tue Dec 19, 2017 10:29 am
io.open() question
I have two directories: [LOVE2D directory] and [App directory]. When I start app from LOVE2D directory using love.exe "App directory", for every newImage, newSource, newFont etc. current directory is [App directory], only for io.open current directory is [LOVE2D directory]. Is this OK? Seems to be little bit inconsistent.
Re: io.open() question
The io. module doesn't work in Love2D as far as I know.
We use "love.filesystem" instead.
I don't think you should need access outside of the game folder.
For saving stuff, you are supposed to use the /%User/AppData/ folder.
We use "love.filesystem" instead.
I don't think you should need access outside of the game folder.
For saving stuff, you are supposed to use the /%User/AppData/ folder.
-
- Prole
- Posts: 11
- Joined: Tue Dec 19, 2017 10:29 am
Re: io.open() question
Is working for me. I used io.open and file:lines.
Now I found love.filesystem.lines
I'll change this in my app for better consistency.
Thank you!
Now I found love.filesystem.lines
I'll change this in my app for better consistency.
Thank you!
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: io.open() question
the io module does work, but it has a few shortcomings, mainly that it's OS-dependent how it works, and that you can't use that with löve's constructor functions (love.*.new*) since those use löve's own filesystem library. (Also, not specifically io-module related, but nowadays, OS-es think they have the right to dictate where programs can read/write, so that can also be a problem.)
Also, where the CWD or current working directory is is dependent on tons of things; even how a batch file is coded can mess with it:
All three of those might have the CWD at different locations, which is why you shouldn't rely on that.
You should use love.filesystem's directory querying functions instead.
Also, where the CWD or current working directory is is dependent on tons of things; even how a batch file is coded can mess with it:
Code: Select all
-- If your bat file is in the directory where love.exe is, then:
love "path/to/project/folder"
-- If it's in your project directory, where main.lua is, then:
"path/to/love.exe" .\
-- If it's anywhere else, then:
"path\to\love.exe" "path/to/project/folder"
You should use love.filesystem's directory querying functions instead.
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.
-
- Prole
- Posts: 11
- Joined: Tue Dec 19, 2017 10:29 am
Re: io.open() question
@zorg
Thanks for the explanation!
Thanks for the explanation!
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 9 guests