Text files input and parsing
Posted: Sat Apr 16, 2016 2:01 pm
Hi everyone. I'm new to LOVE and am really liking it so far, but I'm trying to figure out text file input, which seems a bit different in LUA/LOVE than the languages I'm used to, like C++ and Gamemaker.
I'm planning on using text files as input and output for tiles/maps in my game. The text files will have a grid of integers that are each read and inserted into the cells of a table, which will then refer to quads with the appropriate sprite to show.
I've noticed that there are only two text input functions in LOVE: love.filesystem.lines and love.filesystem.read, neither of which are capable of reading individual characters at a time (I think). So I'm assuming that I will have to do some parsing to the line or block of text before sending it to the table.
At the moment I have some cheap code that just reads anything that isn't whitespace into the table. It works for now, and shows my idea works, but it's very limited and will have to be expanded before it is useful.
How do LOVE users normally implement this sort of text input? Should I use regular expressions (which I will have to learn) to parse the text before sending it to the table? Should I be using LUA's text file input functions instead? (I tried this and it worked but making it able to find the text files in the .love archive was a bit of a pain, and I've read that it is better to use LOVE's text file functions.) Or are there other functions or methods for doing this in LOVE?
Thanks ahead of time!
I'm planning on using text files as input and output for tiles/maps in my game. The text files will have a grid of integers that are each read and inserted into the cells of a table, which will then refer to quads with the appropriate sprite to show.
I've noticed that there are only two text input functions in LOVE: love.filesystem.lines and love.filesystem.read, neither of which are capable of reading individual characters at a time (I think). So I'm assuming that I will have to do some parsing to the line or block of text before sending it to the table.
At the moment I have some cheap code that just reads anything that isn't whitespace into the table. It works for now, and shows my idea works, but it's very limited and will have to be expanded before it is useful.
How do LOVE users normally implement this sort of text input? Should I use regular expressions (which I will have to learn) to parse the text before sending it to the table? Should I be using LUA's text file input functions instead? (I tried this and it worked but making it able to find the text files in the .love archive was a bit of a pain, and I've read that it is better to use LOVE's text file functions.) Or are there other functions or methods for doing this in LOVE?
Thanks ahead of time!