How to loading outside .love 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
dj--alex@ya.ru
Prole
Posts: 23
Joined: Sat Jun 17, 2017 1:23 pm

How to loading outside .love save file?

Post by dj--alex@ya.ru »

m2ktest-load-savegame-test.love
(1001.43 KiB) Downloaded 80 times
Hello. 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 or not /home/local/.love folder.
or it's a bad idea?

HOw to get a bug.
1. Start game
2. Enter menu by Escape key
3. PRess save game - this create savegame
4. Press Load game - you get an error "File not exitst" but you write this file seconds ago.

Image

I successful save a game in savesm2k folder but it folder outside .love file and i don't know how correct load saved game. writemap also used for writing edited map but it creates outside file Level1.$c
For editor and map editing it's ok. (etc load/save for editor works fine but it works bad for player save games)

Used engine: Love2d 0.10.2
OS: Linux Mint 18.1 x64bit kernel 4.10.14

I read many manuals and im in stuck...

For loading save game i use this commands
loadsavegame="yes";
levelname="/M2k-Saves/m2ksave";
pathtosavemap=levelname;
love.load();
and part 2 in Load

ver1: loadsavegamename=love.filesystem.getSaveDirectory().."/M2k-Saves/m2ksave" -
cause a error :: couuld not open /home/user/.local/share/love/data/M2k-Saves/m2ksave does not exist.
ver2: loadsavegamename=love.filesystem.getSourceBaseDirectory().."/M2k-Saves/m2ksave";
Could not open file /media/user/F/Work/RemakingM2K/Love/M2k-Saves/m2ksave Does not exists.
data, size = love.filesystem.read (loadsavegamename);
leveldatacopy=freadbin (data);
Path in ver 2 is CORRECT. Why program don try read EXISTED file? and report no exist?
I try using another command but using GetSaveDirectory broke function WriteMAP (requires for binary map and data writing)
etc. i need getSourceBaseDirectory()... but it write files which cannot be loaded in load section..
I Just don't understand how to resolve this stupid problem.

maybe i should use LUA for reading files direct from folder but i don't know how to correct DO it.
I already waste 15 days for it, and i still no resolve problem,

For save game i use this command (this works))
pathtosavemap=love.filesystem.getSourceBaseDirectory().."/M2k-Saves/m2ksave"; - it always work and save file.
--pathtosavemap=love.filesystem.getSaveDirectory().."/M2k-Saves/m2ksave"; -- always no works
writeMAP(pathtosavemap,xdata);

function writeMAP(filename, t)
local file = love.filesystem.newFile( filename, 'w' )
local file = io.open(filename, 'wb')
data = {};
for i, v in pairs(t) do
data = v;
end
data = table.concat(data)
file:write(data)
file:close (data)
end



. At this moment on every saving i manually replace saved game. 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.
dj--alex@ya.ru
Prole
Posts: 23
Joined: Sat Jun 17, 2017 1:23 pm

Re: How to loading outside .love save file?

Post by dj--alex@ya.ru »

Tries change commands

data=io.input (loadsavegamename);
data=io.open (loadsavegamename,"r");

long reads and don't understood http://www.lua.ru/doc/5.7.html

function freadbin (data)
str = {};
for b in string.gfind(data, ".") dо
....

Result:
bad argument #1 to gfind (string expected got userdata)
https://pp.userapi.com/c841031/v8410312 ... pkLumA.jpg

No work
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to loading outside .love save file?

Post by zorg »

Technically, löve only allows you to access the save directory of your projects for writing; using lua io functions is not recommended since they are not cross-platform compatible. Though it says something when you can't even understand an article in your own language.

Make sure you have set your project's identity via either love.conf or the love.filesystem.setIdentity function.
The path is relative, starting from the root of the save folder, so keep that in mind. (what love.filesystem.getSaveDirectory returns)

The directory may not exist until you actually write a file into it, that is also a caveat.
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.
dj--alex@ya.ru
Prole
Posts: 23
Joined: Sat Jun 17, 2017 1:23 pm

Re: How to loading outside .love save file?

Post by dj--alex@ya.ru »

Okay . What i should do with this nil ?

lsg = "/M2k-Saves/m2ksave"
data, size = love.filesystem.read (lsg);
leveldatacopy=freadbin (data); -- get nil

File exists. but does'nt exist. but file exists but doesn't exist...............

Image
Post Reply

Who is online

Users browsing this forum: No registered users and 100 guests