filename = 'save.txt'
if love.filesystem.exists(filename) then
print('FOUND SAVE FILE!')
print(love.filesystem.load(filename))
else
print('NO SAVE FILE!')
end
love.filesystem.write(filename, 'this is my text string' )
the demo code there, run once saves my file just fine
run again, it does not want to load the file! I get:
FOUND SAVE FILE!
Error: main.lua:9: Syntax error: save.txt:1: '=' expected near 'make'
stack traceback:
[C]: in function 'load'
main.lua:9: in main chunk
[C]: in function 'require'
[string "boot.lua"]:429: in function <[string "boot.lua"]:275>
[C]: in function 'xpcall'
[Finished in 3.3s with exit code 1]
Can anyone help? I have tried updating Love 2D.... It's pretty damn fundamental this bug! For my saves
You do know that love.filesystem.load loads in lua source code, right?
You probably want to open the file, and iterate through the lines, since it's a text file.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
If you just want one string containing all of the file's contents you can just use love.filesystem.read. Alternatively, if you want to iterate over all lines, there is love.filesystem.lines. Lastly, if you need something more complex you can create a File object and read it that way.
yeah i just needed the "read" function... i was finding that very strange, i get it "load" for code, "read" for text
how i didn't spot that when it's the same wording as the lua functions i don't know... i don't really use lines type functions anyway thanks for the info