aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu/gamemgr.lua
blob: b6faa71d9077aa1f49ad7608b4d0ada01640be02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--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 = {}

--------------------------------------------------------------------------------
function gamemgr.find_by_gameid(gameid)
	for i=1,#gamemgr.games,1 do
		if gamemgr.games[i].id == gameid then
			return gamemgr.games[i], i
		end
	end
	return nil, nil
end

--------------------------------------------------------------------------------
function gamemgr.get_game_mods(gamespec, retval)
	if gamespec ~= nil and
		gamespec.gamemods_path ~= nil and
		gamespec.gamemods_path ~= "" then
		get_mods(gamespec.gamemods_path, retval)
	end
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
	end
	return retval
end

--------------------------------------------------------------------------------
function gamemgr.get_game(index)
	if index > 0 and index <= #gamemgr.games then
		return gamemgr.games[index]
	end

	return nil
end

--------------------------------------------------------------------------------
function gamemgr.update_gamelist()
	gamemgr.games = core.get_games()
end

--------------------------------------------------------------------------------
function gamemgr.gamelist()
	local retval = ""
	if #gamemgr.games > 0 then
		retval = retval .. gamemgr.games[1].name

		for i=2,#gamemgr.games,1 do
			retval = retval .. "," .. gamemgr.games[i].name
		end
	end
	return retval
end

--------------------------------------------------------------------------------
-- read initial data
--------------------------------------------------------------------------------
gamemgr.update_gamelist()
class="hl ppc">#define CONTENT_BOOKSHELF 0x814 //29 #define CONTENT_JUNGLETREE 0x815 #define CONTENT_JUNGLEGRASS 0x816 #define CONTENT_NC 0x817 #define CONTENT_NC_RB 0x818 #define CONTENT_APPLE 0x819 #define CONTENT_SAPLING 0x820 /* A conversion table for backwards compatibility. Maps <=v19 content types to current ones. Should never be touched. */ content_t trans_table_19[21][2] = { {CONTENT_GRASS, 1}, {CONTENT_TREE, 4}, {CONTENT_LEAVES, 5}, {CONTENT_GRASS_FOOTSTEPS, 6}, {CONTENT_MESE, 7}, {CONTENT_MUD, 8}, {CONTENT_CLOUD, 10}, {CONTENT_COALSTONE, 11}, {CONTENT_WOOD, 12}, {CONTENT_SAND, 13}, {CONTENT_COBBLE, 18}, {CONTENT_STEEL, 19}, {CONTENT_GLASS, 20}, {CONTENT_MOSSYCOBBLE, 22}, {CONTENT_GRAVEL, 23}, {CONTENT_SANDSTONE, 24}, {CONTENT_CACTUS, 25}, {CONTENT_BRICK, 26}, {CONTENT_CLAY, 27}, {CONTENT_PAPYRUS, 28}, {CONTENT_BOOKSHELF, 29}, }; MapNode mapnode_translate_to_internal(MapNode n_from, u8 version) { MapNode result = n_from; if(version <= 19) { content_t c_from = n_from.getContent(); for (const auto &tt_i : trans_table_19) { if (tt_i[1] == c_from) { result.setContent(tt_i[0]); break; } } } return result; } void content_mapnode_get_name_id_mapping(NameIdMapping *nimap) { nimap->set(0, "default:stone"); nimap->set(2, "default:water_flowing"); nimap->set(3, "default:torch"); nimap->set(9, "default:water_source"); nimap->set(14, "default:sign_wall"); nimap->set(15, "default:chest"); nimap->set(16, "default:furnace"); nimap->set(17, "default:chest_locked"); nimap->set(21, "default:fence_wood"); nimap->set(30, "default:rail"); nimap->set(31, "default:ladder"); nimap->set(32, "default:lava_flowing"); nimap->set(33, "default:lava_source"); nimap->set(0x800, "default:dirt_with_grass"); nimap->set(0x801, "default:tree"); nimap->set(0x802, "default:leaves"); nimap->set(0x803, "default:dirt_with_grass_footsteps"); nimap->set(0x804, "default:mese"); nimap->set(0x805, "default:dirt"); nimap->set(0x806, "default:cloud"); nimap->set(0x807, "default:coalstone"); nimap->set(0x808, "default:wood"); nimap->set(0x809, "default:sand"); nimap->set(0x80a, "default:cobble"); nimap->set(0x80b, "default:steelblock"); nimap->set(0x80c, "default:glass"); nimap->set(0x80d, "default:mossycobble"); nimap->set(0x80e, "default:gravel"); nimap->set(0x80f, "default:sandstone"); nimap->set(0x810, "default:cactus"); nimap->set(0x811, "default:brick"); nimap->set(0x812, "default:clay"); nimap->set(0x813, "default:papyrus"); nimap->set(0x814, "default:bookshelf"); nimap->set(0x815, "default:jungletree"); nimap->set(0x816, "default:junglegrass"); nimap->set(0x817, "default:nyancat"); nimap->set(0x818, "default:nyancat_rainbow"); nimap->set(0x819, "default:apple"); nimap->set(0x820, "default:sapling");