2019-07-26 17:36:25 +02:00
|
|
|
local gameutils = {}
|
|
|
|
|
|
|
|
function gameutils.getMapPath(maptype, mapname)
|
2019-07-26 20:22:18 +02:00
|
|
|
local dir = gameutils.getMapDirectory(maptype, mapname)
|
2019-07-27 14:41:02 +02:00
|
|
|
local path = ""
|
|
|
|
if maptype == "sti" then
|
|
|
|
path = dir .. "map.lua"
|
|
|
|
else
|
|
|
|
path = "datas.gamedata.maps." .. maptype .. "." .. mapname
|
|
|
|
end
|
2019-07-26 20:22:18 +02:00
|
|
|
core.debug:print("game/utils", "path is " .. path)
|
|
|
|
return path
|
2019-07-26 17:36:25 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function gameutils.getMapDirectory(maptype, mapname)
|
2019-07-27 11:05:54 +02:00
|
|
|
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
|
|
|
|
|
2019-07-27 11:05:54 +02:00
|
|
|
function gameutils.validateMapType(maptype)
|
2019-08-02 13:54:04 +02:00
|
|
|
local types = {"battle", "sti", "test", "shoot"}
|
2019-07-27 11:05:54 +02:00
|
|
|
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
|