diff options
author | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-10-24 01:19:24 +0200 |
---|---|---|
committer | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-10-24 01:19:24 +0200 |
commit | 6a55251a4526095fb691f5fca0a9d51c0d1cf7c0 (patch) | |
tree | 5c43ed7b9c281d59ef8321f858177962150269bb /pacmine/hud.lua | |
parent | 6b949da2c7610c55f2bb83c693520b9e77a9aebc (diff) |
Moved and renamed to pacmine
Diffstat (limited to 'pacmine/hud.lua')
-rwxr-xr-x | pacmine/hud.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pacmine/hud.lua b/pacmine/hud.lua new file mode 100755 index 0000000..162917d --- /dev/null +++ b/pacmine/hud.lua @@ -0,0 +1,43 @@ + + +local hud_table = {} + +function pacmine.update_hud(id, player) + local game = pacmine.games[id] + player = player or minetest.get_player_by_name(game.player_name) + if not player then + return + elseif not game then + pacmine.remove_hud(player) + return + end + + local hudtext = "Score: " .. game.score + .. "\nLevel: " .. game.level + .. "\nLives: " .. game.lives + + local hud = hud_table[game.player_name] + if not hud then + hud = player:hud_add({ + hud_elem_type = "text", + position = {x = 0, y = 1}, + offset = {x=100, y = -100}, + scale = {x = 100, y = 100}, + number = 0x8888FF, --color + text = hudtext + }) + hud_table[game.player_name] = hud + else + player:hud_change(hud, "text", hudtext) + end +end + + +function pacmine.remove_hud(player, playername) + local name = playername or player:get_player_name() + local hud = hud_table[name] + if hud then + player:hud_remove(hud) + hud_table[name] = nil + end +end |