1 local minetest = minetest
3 local player_huds = {} -- the list of players hud lists (3d array)
4 hud_manager = {} -- hud manager class
6 -- terminate the player's list on leave
7 minetest.register_on_leaveplayer(function(player)
8 local name = player:get_player_name()
9 player_huds[name] = nil
12 -- create instance of new hud
13 hud_manager.add_hud = function(player,hud_name,def)
14 local name = player:get_player_name()
15 local local_hud = player:hud_add({
16 hud_elem_type = def.hud_elem_type,
17 position = def.position,
20 direction = def.direction,
24 -- create new 3d array here
25 -- depends.txt is not needed
27 if not player_huds[name] then
28 player_huds[name] = {}
31 player_huds[name][hud_name] = local_hud
34 -- delete instance of hud
35 hud_manager.remove_hud = function(player,hud_name)
36 local name = player:get_player_name()
37 if player_huds[name] and player_huds[name][hud_name] then
38 player:hud_remove(player_huds[name][hud_name])
39 player_huds[name][hud_name] = nil
43 -- change element of hud
44 hud_manager.change_hud = function(data)
45 local name = data.player:get_player_name()
46 if player_huds[name] and player_huds[name][data.hud_name] then
47 data.player:hud_change(player_huds[name][data.hud_name], data.element, data.data)
52 hud_manager.hud_exists = function(player,hud_name)
53 local name = player:get_player_name()
54 if player_huds[name] and player_huds[name][hud_name] then