Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.
Moderator: Coders of Rage
cndr
Chaos Rift Cool Newbie
Posts: 65 Joined: Sat Apr 24, 2010 7:03 am
Programming Language of Choice: etc.
Post
by cndr » Sat Apr 24, 2010 7:22 pm
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?
Last edited by
cndr on Sat Apr 24, 2010 10:07 pm, edited 1 time in total.
Long Live The Queen!
GroundUpEngine
Chaos Rift Devotee
Posts: 835 Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK
Post
by GroundUpEngine » Sat Apr 24, 2010 8:11 pm
Something like this I think, my Lua is rusty as hell though
Code: Select all
file = io.open("Age.txt","w") --"w" is Overwrite and "a" is Append
file:write(age)
file:close()
cndr
Chaos Rift Cool Newbie
Posts: 65 Joined: Sat Apr 24, 2010 7:03 am
Programming Language of Choice: etc.
Post
by cndr » Sat Apr 24, 2010 10:07 pm
worked perfectly thanks for the help!
Long Live The Queen!
GroundUpEngine
Chaos Rift Devotee
Posts: 835 Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK
Post
by GroundUpEngine » Sun Apr 25, 2010 11:51 am
cndr wrote: worked perfectly thanks for the help!
No Prob, hmm I might start using Lua again! :D