Page 2 of 3

Re: Saving Data

Posted: Thu Jul 04, 2013 8:19 pm
by Plu
If you're using Lua's own I/O it might end up somewhere else. I can't really tell you. But probably still not the source folder.

(You could always write a file with a unique name and search your PC for it)

Re: Saving Data

Posted: Thu Jul 04, 2013 8:49 pm
by Eamonn
Ok so what you do is write this in love.conf:

Code: Select all

function love.conf(t)
    t.screen.width = 800 -- This doesn't matter
    t.screen.height = 600 -- This doesn't matter either
    t.title = "My little help example!!" -- Nor does this!
    t.author = "Eamonn Rea" -- This is semi-important
    t.identity = "Your_game_name" -- This is important
end
Ok, so the 't.identity' part sets the name of your games save folder. So put in your game's name there, save and run your code, go into that directory again and you should see the folder. Any files you write to will be put there automatically(though I believe you can change this, it isn't really necessary at this point).

Any other problems just ask :)

I recommend using love.filesystem. It's better for LÖVE games. I've never used standard Lua I/0, so I can't help you there :( Sorry!

Re: Saving Data

Posted: Fri Jul 05, 2013 5:41 am
by T-Bone
Yes, without a doubt should you use love.filesystem. Much easier to work with.

Re: Saving Data

Posted: Fri Jul 05, 2013 12:31 pm
by MPQC
Life would be so much simpler with SQLite. :awesome:

Re: Saving Data

Posted: Fri Jul 05, 2013 2:01 pm
by Bobbias
Quick, embed SQLite into a Love fork!

I do wish love.filesystem had easy binary file capability though. Sometimes flat binary output is just better than text.

Re: Saving Data

Posted: Fri Jul 05, 2013 2:13 pm
by bartbes
It does, it doesn't know a binary mode, it's always in binary mode. If you produce the binary, it saves and loads it.

Re: Saving Data

Posted: Fri Jul 05, 2013 3:25 pm
by Bobbias
I stand corrected. I've yet to work with files anyway.

Re: Saving Data

Posted: Sat Jul 06, 2013 12:05 am
by Lemony Lime
I've got it mostly sorted out, but there's one more big problem. How do you read either a specific byte or specific line of a file? Either way works. If it's not possible, then love just can't do what I'm trying to do. love.filesystem.lines and file:read don't work, because they force you to start at the beginning of the file. I need to be able to pick a line or a byte at will and read it directly.

Re: Saving Data

Posted: Sat Jul 06, 2013 3:34 am
by Lemony Lime
Fun fact, Lua's file IO will write files to the LOVE install directory.

Re: Saving Data

Posted: Sat Jul 06, 2013 5:17 am
by Boolsheet
If you give the Lua IO library a relative path, it will be relative to the working directory. On Windows, if you use a shortcut it usually points to working directory to the executable which seems to be the LÖVE program files directory for you.