Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ how do i get a newline in io.write?
how do i get a newline in io.write?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Braindead
Netherlands (2 posts) Bio
|
Date
| Thu 31 May 2007 02:58 PM (UTC) Amended on Thu 31 May 2007 03:21 PM (UTC) by Braindead
|
Message
| I'm trying to save multiple arrays to the same file, but to read them successfully I need to know how to add a new line to the file.
code used for saving:
Quote:
f = io.output (MobFileName)
c = 0
if ArrayListAll() then
for k, a in pairs (ArrayListAll ()) do
if ArrayKeyExists (a, "Type") then
if ArrayGet (a, "Type") == "Mob" then
c = c + 1
f:write (ArrayExport (a, ";"))
end -- if
end -- if
end -- for
end -- if
f:close ()
code used for loading:
Quote:
f = io.input (MobFileName)
c = 0
repeat
s = f:read ("*l")
if s then
ArrayImport (ArrID,s,";")
some code here to process data
ArrayClear (ArrID)
c = c + 1
end -- if
until not s
f:close ()
|
If there is such a thing as Heaven and Hell then I'm royally scr3wed | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #1 on Thu 31 May 2007 03:46 PM (UTC) Amended on Thu 31 May 2007 03:49 PM (UTC) by Shaun Biggs
|
Message
| f:write("\n")
Just tack it on the end of each individual line.
f:write ("foo\n") |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Braindead
Netherlands (2 posts) Bio
|
Date
| Reply #2 on Thu 31 May 2007 04:00 PM (UTC) |
Message
| Duh, I thought I tried that, but I used /n instead.
Thanks |
If there is such a thing as Heaven and Hell then I'm royally scr3wed | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #3 on Thu 31 May 2007 04:49 PM (UTC) |
Message
| That's ok, if it makes you feel any better, I spent two hours yesterday trying to figure out why I wasn't able to put a \ into a string. Forgot that I needed "\\" to do that. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
20,624 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top