file i/o NOOB here

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
darklitch
Posts: 11
Joined: Mon Oct 03, 2005 9:55 am
Contact:

file i/o NOOB here

Post by darklitch »

How can i show new lines with file i/o? I am using the script:
highscoreFile = "1.txt"
function loadHighscore()
file = io.open(highscoreFile, "r")
if file then
high = file:read()
file:close()
end
end

when I edit the highscoreFile to:
asdf
adf
adfjkald

I get jkdsf then a musical note to appear. How can i get
asdf
adf
adfjkald
to appear?
Last edited by darklitch on Sun Nov 06, 2005 2:49 am, edited 1 time in total.
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

Look at the snake example.
darklitch
Posts: 11
Joined: Mon Oct 03, 2005 9:55 am
Contact:

Post by darklitch »

i don't think the snake example uses more than one line
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

It does. The options do.

I've created my own parody of Lua called LUAH. Of course, it runs in luaplayer, you edit a file called index.LUAH. It has the commands: clearscreen(color), display(text), refreshscreen(), wait(time in milliseconds), wait(start) [wait till start is pushed], while not start end, and /LUA/ followed by a LUA command. It works by analizing each line, then writes to a new Luaplayer file called 'luah.luah. It then runs it.

It should look something like: (well, not exaclty, I forgot the open commad)

file = ioopen("file", "*r")
for line in file:lines() do
end
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

new line is system dependend "\r" or "\n" some use combinations "\n\r" (or the other way around...)

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Post Reply