Page 1 of 1

[Solved] writing to file with Lua

Posted: Sat Apr 24, 2010 7:22 pm
by cndr
I am attempting to learn lua, can't find too many tutorials online, but I would like to write to a file

Code: Select all

io.write("What is your age: ")
age = io.read() 
print ("You are " .. age .. " years old"); --now I would like to write this line to a file, how would I go about doing this?

Re: writing to file with Lua

Posted: Sat Apr 24, 2010 8:11 pm
by GroundUpEngine
Something like this I think, my Lua is rusty as hell though :lol:

Code: Select all

file = io.open("Age.txt","w") --"w" is Overwrite and "a" is Append
file:write(age)
file:close()

Re: [Solved] writing to file with Lua

Posted: Sat Apr 24, 2010 10:07 pm
by cndr
worked perfectly thanks for the help!

Re: [Solved] writing to file with Lua

Posted: Sun Apr 25, 2010 11:51 am
by GroundUpEngine
cndr wrote:worked perfectly thanks for the help!
No Prob, hmm I might start using Lua again! :D