Page 1 of 1

Creating a .txt file and writing a string in it

Posted: Sat Apr 26, 2014 11:56 pm
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

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

Posted: Sun Apr 27, 2014 12:10 am
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)

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

Posted: Sun Apr 27, 2014 12:40 am
by xFade
Thank you :D