A lua script that uses io.lines for reading a txt file does not work in löve
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- scissors61
- Citizen
- Posts: 76
- Joined: Fri Jan 08, 2016 10:16 am
A lua script that uses io.lines for reading a txt file does not work in löve
I created a script that reads through the text of a txt file to create a table and to add some values to each entry, well it does not work when I try to use it with löve, it says that when doing io.lines the txt file does not exists. Is lua limited when used in löve?
- Attachments
-
- japanese.love
- (3.01 MiB) Downloaded 121 times
Re: A lua script that uses io.lines for reading a txt file does not work in löve
Instead of using the Lua reading function, use 'love.filesystem.lines'. Also Love cannot read anything outside of the game directory without some finesse. There are ways to do it, but it's more like a workaround.
- scissors61
- Citizen
- Posts: 76
- Joined: Fri Jan 08, 2016 10:16 am
Re: A lua script that uses io.lines for reading a txt file does not work in löve
It worked!, I thought that lua worked completely in löve, but in some aspects it is kind of like box2d, were it has its own way of implementing things, Thanks Beelz!
Re: A lua script that uses io.lines for reading a txt file does not work in löve
It's still Lua (LuaJIT actually). Lua isn't able to directly read files stored in .zip's and so isn't LÖVE. In order to access the files stored in the .love file or in your game directory, LÖVE provides the pertinent love.filesystem functions. You can think of the love.filesystem functions as a workaround for these Lua limitations.
Your program works fine for me when unzipped and run from the same directory with 'love .'
Edit: This works:
(in the directory with your unpacked files):
love .
lua convertidor.lua
This doesn't:
(in a different directory):
love <path to your unpacked files>
lua <path to your unpacked files>/convertidor.lua
love <your .love file>
lua <your .love file>/convertidor.lua
Your program works fine for me when unzipped and run from the same directory with 'love .'
Edit: This works:
(in the directory with your unpacked files):
love .
lua convertidor.lua
This doesn't:
(in a different directory):
love <path to your unpacked files>
lua <path to your unpacked files>/convertidor.lua
love <your .love file>
lua <your .love file>/convertidor.lua
- zorg
- Party member
- Posts: 3444
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: A lua script that uses io.lines for reading a txt file does not work in löve
If i recall correctly, it also works if you have the game in a love, and you get the source base directory, that will be the directory that contains the love file.
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.
- scissors61
- Citizen
- Posts: 76
- Joined: Fri Jan 08, 2016 10:16 am
Re: A lua script that uses io.lines for reading a txt file does not work in löve
It is not clear to me yet from what I read from you guys, but the io.line script might work but only if the file is outside of the compressed .love app? Anyway, the game is complete, or the simple app,it is for a study group, it would be nice if it could read a txt file outside the compressed .love file, well this is my second thing I create with löve, I upload it if anyone wants to see, or learn the causative form of the japanese language ( yay!), the first thing I created was a game called cars avoiding cars with irregular hitboxes.
- Attachments
-
- japanese.love
- (3.11 MiB) Downloaded 96 times
Who is online
Users browsing this forum: Google [Bot] and 61 guests