sonic-radiance/sonic-radiance.love/game/modules/utils/init.lua

37 lines
855 B
Lua
Raw Permalink Normal View History

2019-07-26 17:36:25 +02:00
local gameutils = {}
function gameutils.getMapPath(maptype, mapname)
local dir = gameutils.getMapDirectory(maptype, mapname)
local path = ""
if maptype == "sti" then
path = dir .. "map.lua"
else
path = "datas.gamedata.maps." .. maptype .. "." .. mapname
end
core.debug:print("game/utils", "path is " .. path)
return path
2019-07-26 17:36:25 +02:00
end
function gameutils.getMapDirectory(maptype, mapname)
if not gameutils.validateMapType(maptype) then
2019-07-26 17:36:25 +02:00
error("Map type " .. maptype .. " doesn't exist.")
end
return "datas/gamedata/maps/" .. maptype .. "/" .. mapname .. "/"
end
function gameutils.validateMapType(maptype)
local types = {"battle", "sti", "test", "shoot"}
local validated = false
for i, type in ipairs(types) do
if (type == maptype) then
validated = true
end
end
return validated
end
2019-07-26 17:36:25 +02:00
return gameutils