2013-06-23 12:30:21 -04:00
|
|
|
--Minetest
|
|
|
|
--Copyright (C) 2013 sapier
|
|
|
|
--
|
|
|
|
--This program is free software; you can redistribute it and/or modify
|
|
|
|
--it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
--the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
--(at your option) any later version.
|
|
|
|
--
|
|
|
|
--This program is distributed in the hope that it will be useful,
|
|
|
|
--but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
--GNU Lesser General Public License for more details.
|
|
|
|
--
|
|
|
|
--You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
--with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
gamemgr = {}
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2013-08-19 07:55:04 -04:00
|
|
|
function gamemgr.find_by_gameid(gameid)
|
2014-04-18 09:39:15 -04:00
|
|
|
for i=1,#gamemgr.games,1 do
|
2013-08-19 07:55:04 -04:00
|
|
|
if gamemgr.games[i].id == gameid then
|
|
|
|
return gamemgr.games[i], i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return nil, nil
|
|
|
|
end
|
2013-06-23 12:30:21 -04:00
|
|
|
|
2013-08-19 07:55:04 -04:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function gamemgr.get_game_mods(gamespec, retval)
|
|
|
|
if gamespec ~= nil and
|
|
|
|
gamespec.gamemods_path ~= nil and
|
2013-06-23 12:30:21 -04:00
|
|
|
gamespec.gamemods_path ~= "" then
|
2013-08-19 07:55:04 -04:00
|
|
|
get_mods(gamespec.gamemods_path, retval)
|
2013-06-23 12:30:21 -04:00
|
|
|
end
|
2013-08-19 07:55:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function gamemgr.get_game_modlist(gamespec)
|
|
|
|
local retval = ""
|
|
|
|
local game_mods = {}
|
|
|
|
gamemgr.get_game_mods(gamespec, game_mods)
|
|
|
|
for i=1,#game_mods,1 do
|
|
|
|
if retval ~= "" then
|
|
|
|
retval = retval..","
|
|
|
|
end
|
|
|
|
retval = retval .. game_mods[i].name
|
2013-06-23 12:30:21 -04:00
|
|
|
end
|
|
|
|
return retval
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2014-04-18 09:39:15 -04:00
|
|
|
function gamemgr.get_game(index)
|
2013-06-23 12:30:21 -04:00
|
|
|
if index > 0 and index <= #gamemgr.games then
|
|
|
|
return gamemgr.games[index]
|
|
|
|
end
|
2014-04-18 09:39:15 -04:00
|
|
|
|
2013-06-23 12:30:21 -04:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function gamemgr.update_gamelist()
|
2014-04-18 09:39:15 -04:00
|
|
|
gamemgr.games = core.get_games()
|
2013-06-23 12:30:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
function gamemgr.gamelist()
|
|
|
|
local retval = ""
|
|
|
|
if #gamemgr.games > 0 then
|
2014-10-16 14:23:02 -04:00
|
|
|
retval = retval .. gamemgr.games[1].name
|
2014-04-18 09:39:15 -04:00
|
|
|
|
2013-06-23 12:30:21 -04:00
|
|
|
for i=2,#gamemgr.games,1 do
|
|
|
|
retval = retval .. "," .. gamemgr.games[i].name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return retval
|
|
|
|
end
|
2014-04-18 09:39:15 -04:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- read initial data
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
gamemgr.update_gamelist()
|