Page 1 of 2

saving files to game directory

Posted: Wed Sep 19, 2012 11:02 am
by russ_e
Hey all,
I'm trying to figure out how to get my little game running as a .love file, and its complaining that it cant find files, which makes sense, since they're not saved in the main game directory. I've looked, and cant find any info anywhere about how to change the directory you're saving in from the ...AppData\Roaming\LOVE\gamename directory to the ...love\game directory.

my first ATTEMPT to get it working with a local directory was something like this (didnt work :( )

Code: Select all

function map_startup()
	current_map = "map1.lua"
	map_path = "states/game/maps/"
	load_map()
end

function load_map()
	
	local file = love.filesystem.newFile(map_path..current_map)
	local temp_string_map = {}
	local new_map = {}
	
	map = {}  --GLOBAL

	for line in love.filesystem.lines(map_path..current_map) do
		table.insert(temp_string_map, line)
	end
	
	map_h = #temp_string_map
	map_w = string.len(temp_string_map[1])
	
	for y = 1, map_h do
		new_map = {}
		tempstring = string.sub(temp_string_map[y], 1, map_w)
		for x = 1, map_w do
			new_map[x] = tonumber(string.sub(tempstring, x, x))
		end
		
		table.insert(map, new_map)
	end	
end
Help greatly appreciated :)

Once i get this working, i'll probably be back within seconds to ask if anyone can help figure out why my collision detection is so flakey :P

Re: saving files to game directory

Posted: Wed Sep 19, 2012 11:06 am
by coffee
russ_e wrote:and cant find any info anywhere about how to change the directory you're saving in from the ...AppData\Roaming\LOVE\gamename directory to the ...love\game directory.
You are probably looking for this.
https://love2d.org/wiki/love.filesystem.setIdentity
However you are always limited in save area choices. But you can load from whatever place you want inside your LOVE file.
Check the limitations here
https://love2d.org/wiki/love.filesystem

Re: saving files to game directory

Posted: Wed Sep 19, 2012 11:20 am
by russ_e
many thanks :D

<3

Re: saving files to game directory

Posted: Wed Sep 19, 2012 12:08 pm
by Roland_Yonaba
Just to mention that, working with Love 0.8.0, you can also set that in your conf.lua.

Code: Select all

function love.conf(config)
	config.identity = "whatever"
end

Re: saving files to game directory

Posted: Sat Sep 22, 2012 6:52 pm
by russ_e
Ok, that seems to work for loading files - can i change the directory it saves out to? They always seem to get thrown in roaming, despite my better efforts...

Re: saving files to game directory

Posted: Sat Sep 22, 2012 7:23 pm
by Nixola
It's the only directory where programs can write without asking for administrator rights, so it will only write in there.

Re: saving files to game directory

Posted: Sat Sep 22, 2012 8:51 pm
by russ_e
Ah, that's rather rubbish, I'll have to fiddle with stuff to get my level editor working.

Thanks very much for the answer though :)

Re: saving files to game directory

Posted: Sun Sep 23, 2012 8:23 am
by Roland_Yonaba
Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the only directory where love.filesystem can write files. These directories will typically be found in something like:
Seen on love.filesystem.

Re: saving files to game directory

Posted: Sun Sep 23, 2012 8:41 am
by coffee
Roland_Yonaba wrote:
Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the only directory where love.filesystem can write files. These directories will typically be found in something like:
Seen on love.filesystem.
russ_e is for some reason ignoring what we (and LOVE wiki) say to him. He already was warned before about the limitations.
You are probably looking for this.
https://love2d.org/wiki/love.filesystem.setIdentity
However you are always limited in save area choices. But you can load from whatever place you want inside your LOVE file.
Check the limitations here
https://love2d.org/wiki/love.filesystem
russ_e is a very distracted person. :D

Re: saving files to game directory

Posted: Sun Sep 23, 2012 3:58 pm
by russ_e
Sorry if i upset you, coffee, i'm just new and asking for help. I guess i'll go elsewhere in the future.