Can't Make A Save File

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
JaredFuntime
Prole
Posts: 3
Joined: Fri Oct 28, 2016 8:12 pm

Can't Make A Save File

Post by JaredFuntime »

Hey there, I need some help on making a save file on a Love2D game.

Here is my code below:

Code: Select all

local data
local quit = true

function love.load()
  cmd = require('require.lovecmd')

  if not love.filesystem.exists('sav.klopman') then
    data = {}
    print('Oh!  Hello there.  I must have been expecting you.')
  else
    data = love.filesystem.load('sav.klopman')
    print('Ah, welcome back, dear player.  Ready to continue playing?')
  end
end

function love.quit()
  if quit then
    print('Are you sure you want to save before quitting?')
    quit = false
  else
    io.write('sav.klopman')
    return quit
  end
  return true
end
Now don't ask me why I chose '.klopman' as the extension, but can you help me fix it?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Can't Make A Save File

Post by zorg »

io.write writes to the standard output by default, or in other words, the same place the print function writes to.
Since you do want to use love.filesystem functions instead of lua's io ones, for file manipulation, you should use love.filesystem.write instead.

Also, it wouldn't hurt actually writing something into the file... but of course, you can have a bunch of empty files too, i'm not here to judge. :P
Me and my stuff :3True 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.
JaredFuntime
Prole
Posts: 3
Joined: Fri Oct 28, 2016 8:12 pm

Re: Can't Make A Save File

Post by JaredFuntime »

Nevermind, I already got it, because I was waiting for moderator's approval.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests