loading multi line .txt
Moderators: Shine, Insert_witty_name
-
- Posts: 31
- Joined: Sat Oct 15, 2005 10:56 am
loading multi line .txt
i know that there is an example of loading multiple lines in snake. however ive been staring at it and fiddling with it for a while. i just cant get it to work right. can someone explain it in a bit of detail?
-
- Posts: 31
- Joined: Sat Oct 15, 2005 10:56 am
Note: this is not a general Lua forum and reading the manual at http://www.lua.org/manual/5.0/manual.html and "Programming In Lua" at http://www.lua.org/pil/ would have solved your problem.
But lets take a look at snake, I don't see your problem, this loads already multiple lines:
If you don't want to process each single file, but want to load the whole file in a string, take a look at http://www.lua.org/pil/21.1.html and write it like this:
But lets take a look at snake, I don't see your problem, this loads already multiple lines:
Code: Select all
file = io.open("yourfile.txt, "r")
if file then
for line in file:lines() do
-- do something with "line"
end
file:close()
end
Code: Select all
file = io.open("yourfile.txt, "r")
if file then
text = file:read("*a")
-- do something with "text"
file:close()
end