interacting with txt files?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 43
- Joined: Sun Dec 25, 2011 5:13 pm
interacting with txt files?
Is there a way to read a txt file? Like getting the contents of it and putting it into a string?
Re: interacting with txt files?
love.filesystem seems to be what you're looking for. Particularly http://love2d.org/wiki/love.filesystem.read ?
Re: interacting with txt files?
This may not be the proper way to do it but I find it very easy to use:
and on "map1.lua", in the working directory:
Code: Select all
mapstring = love.filesystem.load("map1.lua")() -- the last parenthesis execute the code
Code: Select all
return { "0011000\n0000001\n0010011" }
- Jasoco
- Inner party member
- Posts: 3725
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: interacting with txt files?
Both are correct. The former will load a text file in as lines. The latter executes it as if it's code. Using the return in the loaded file will return it through the load function.
Who is online
Users browsing this forum: Bing [Bot] and 3 guests