Creating a .txt file and writing a string in it

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
xFade
Prole
Posts: 41
Joined: Mon Dec 23, 2013 6:04 pm

Creating a .txt file and writing a string in it

Post by xFade »

Code: Select all

a = "testy test" 
f = love.filesystem.newFile("Test.txt")
f:open("w")
f:write(a)
f:close()
How would I do so? I tried the above code but it doesn't work :/ It is in main.lua
(ง'̀-'́)ง
User avatar
slime
Solid Snayke
Posts: 3171
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Creating a .txt file and writing a string in it

Post by slime »

Keep in mind files will only be written to the game's save directory, which is in %appdata%/LOVE/gamename/ in Windows.

The code there should work, but it can also be done like this:

Code: Select all

a = "testy test" 
love.filesystem.write("Test.txt", a)
User avatar
xFade
Prole
Posts: 41
Joined: Mon Dec 23, 2013 6:04 pm

Re: Creating a .txt file and writing a string in it

Post by xFade »

Thank you :D
(ง'̀-'́)ง
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests