diff options
author | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-10-22 22:21:35 +0200 |
---|---|---|
committer | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-10-22 22:21:35 +0200 |
commit | 2707c8a21c89955ae1aa3012eb9b2ed97c74226b (patch) | |
tree | 085e10f388236ca0f07a165de963e4ced8af7d1d /scorehud.lua | |
parent | 9fc6dc36feac4888ee10a8ee9aeb4fffc2f6e80a (diff) |
Added score HUD
Diffstat (limited to 'scorehud.lua')
-rwxr-xr-x | scorehud.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scorehud.lua b/scorehud.lua new file mode 100755 index 0000000..dbdfd7f --- /dev/null +++ b/scorehud.lua @@ -0,0 +1,35 @@ + + +local hud_table = {} + +function mypacman.update_hud(id, player) + local game = mypacman.games[id] + player = player or minetest.get_player_by_name(game.player_name) + if not player then + return + end + local hudtext = "Score: " .. game.score + local hud = hud_table[game.player_name] + if not hud then + hud = player:hud_add({ + hud_elem_type = "text", + position = {x = 1, y = 0}, + offset = {x=-400, y = 75}, + scale = {x = 100, y = 100}, + number = 0xFFFFFF, --color + text = hudtext + }) + hud_table[game.player_name] = hud + else + player:hud_change(hud, "text", hudtext) + end +end + + +function mypacman.remove_hud(player, playername) + local name = playername or player:get_player_name() + local hud = hud_table[name] + if hud then + player:hud_remove(hud) + end +end |