Reputation: 1
I write editor and game and it requires a save game option. I Just want use a Save folder in game folder. not inside.love
How to get a bug.
I successful save a game in savesm2k folder but it folder outside .love file and i don't know how correct load saved game.
Used engine: Love2d 0.10.2 OS: Linux Mint 18.1 x64bit
I read many manuals and I'm stuck.
For loading save game i use this commands
lsg=love.filesystem.getSaveDirectory().."/M2k-Saves/m2ksave"
lsg=love.filesystem.getSourceBaseDirectory().."/M2k-Saves/m2ksave";
data, size = love.filesystem.read (lsg);
leveldatacopy=freadbin (data);
Why does the program not try read existing file? and report no exist? I try using another command but using GetSaveDirectory broke function WriteMAP (requires for binary map and data writing) etc. but it write files which cannot be loaded in load section.
Maybe I should use LUA for reading files direct from folder but I don't know how to correct DO it.
example with bug. https://github.com/dj--alex/m2ktest file m2ktest-load-savegame-test.love
At this moment on every saving i manually replace saved game inside love archive (!) . This is not normal.
Anybody can tell me how i get and correct open saved file? Not from inside .love file . from outside of course. If levels and configs can be readed from love file inside save files must be outside. I can only can create files outside love file . i know love file is a zip archive.
If required i can post a .love file but is game completely done and have 150kb of clean code.
Upvotes: 0
Views: 1202
Reputation: 4264
You should not prefix paths with love.filesystem.getSaveDirectory()
or love.filesystem.getSourceBaseDirectory()
. This is done automatically, internally to the love.filesystem
functions. Saying
lsg = "/M2k-Saves/m2ksave"
data, size = love.filesystem.read (lsg)
leveldatacopy = freadbin (data)
should work, and will place the file in the save directory / outside of the .love file or game directory. (Love forbids writing anywhere except in the save directory.)
Love's filesystem model is like a "stack" of filesystems. For file reading, it first looks in love.filesystem.getSaveDirectory()
with whatever path you pass in. If it finds a file, it uses that; otherwise it looks inside the love.filesystem.getSourceBaseDirectory()
(or – if packed – inside the .zip / .love file). Writing files always goes to love.filesystem.getSaveDirectory()
, you cannot write to love.filesystem.getSourceBaseDirectory()
(because it may not be an actual directory but a zip file).
Upvotes: 0