function love.load()
--load stuff
end
function love.update()
-- things
if love.keyboard.isDown("return") then
if love.filesystem.getInfo(game.file_n) then
love.filesystem.write(game.file_n, game.txt)
else
love.filesystem.newFile(game.file_n..".lua")
love.filesystem.write(game.file_n, game.txt)
end
love.event.quit()
end
end
function love.draw()
--draw stuff
end
Last edited by zalander on Sun Jun 18, 2023 11:15 am, edited 1 time in total.
Did you forget the quotes around "game.txt"? I assume you want that as a filename and not a variable.
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 love.keyboard.isDown("return") then
local success, message = love.filesystem.write(game.file_n, game.txt)
if success then
print("File saved successfully!")
else
print("Error saving file:", message)
end
end
The naming was a bit confusing, since i assumed the second parameter was the filename when it wasn't;
what's in game.file_n ?
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.
zorg wrote: ↑Sat Jun 17, 2023 8:02 am
The naming was a bit confusing, since i assumed the second parameter was the filename when it wasn't;
what's in game.file_n ?
game.file_n contains a string which is the file name
if love.keyboard.isDown("return") then
local success, message = love.filesystem.write(game.file_n, game.txt)
if success then
print("File saved successfully!")
else
print("Error saving file:", message)
end
end
if love.keyboard.isDown("return") then
local success, message = love.filesystem.write(game.file_n, game.txt)
if success then
print("File saved successfully!")
else
print("Error saving file:", message)
end
end