forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

loading multi line .txt

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Sun Dec 11, 2005 3:52 am    Post subject: loading multi line .txt Reply with quote

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?
Back to top
View user's profile Send private message
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Sun Dec 11, 2005 10:06 am    Post subject: Reply with quote

nevermind...i went with creating a bunch of .txts just to get it done. but if anyone still wants to answer im sure others (still including me) would be interested.
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Sun Dec 11, 2005 10:29 am    Post subject: Reply with quote

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:

Code:

file = io.open("yourfile.txt, "r")
if file then
   for line in file:lines() do
      -- do something with "line"
   end
   file:close()
end


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:

Code:

file = io.open("yourfile.txt, "r")
if file then
   text = file:read("*a")
   -- do something with "text"
   file:close()
end
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group