saving files to game directory
Posted: Wed Sep 19, 2012 11:02 am
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 )
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
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
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