forked from mtcontrib/minetest_mana
Code cleanup
This commit is contained in:
parent
4e18900a39
commit
d400f20c55
60
init.lua
60
init.lua
@ -261,35 +261,33 @@ if minetest.get_modpath("hudbars") ~= nil then
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
function mana.manastring(playername)
|
||||||
function mana.manastring(playername)
|
return string.format("Mana: %d/%d", mana.get(playername), mana.getmax(playername))
|
||||||
return string.format("Mana: %d/%d", mana.get(playername), mana.getmax(playername))
|
end
|
||||||
end
|
|
||||||
|
function mana.hud_add(playername)
|
||||||
function mana.hud_add(playername)
|
local player = minetest.get_player_by_name(playername)
|
||||||
local player = minetest.get_player_by_name(playername)
|
id = player:hud_add({
|
||||||
id = player:hud_add({
|
hud_elem_type = "text",
|
||||||
hud_elem_type = "text",
|
position = { x = 0.5, y=0.9 },
|
||||||
position = { x = 0.5, y=0.9 },
|
text = mana.manastring(playername),
|
||||||
text = mana.manastring(playername),
|
scale = { x = 0, y = 0 },
|
||||||
scale = { x = 0, y = 0 },
|
alignment = { x = 1, y = 0},
|
||||||
alignment = { x = 1, y = 0},
|
direction = 1,
|
||||||
direction = 1,
|
number = 0xFFFFFF,
|
||||||
number = 0xFFFFFF,
|
offset = { x = -200, y = 15}
|
||||||
offset = { x = -200, y = 15}
|
})
|
||||||
})
|
mana.playerlist[playername].hudid = id
|
||||||
mana.playerlist[playername].hudid = id
|
return id
|
||||||
return id
|
end
|
||||||
end
|
|
||||||
|
function mana.hud_update(playername)
|
||||||
function mana.hud_update(playername)
|
local player = minetest.get_player_by_name(playername)
|
||||||
local player = minetest.get_player_by_name(playername)
|
player:hud_change(mana.playerlist[playername].hudid, "number", mana.get(playername))
|
||||||
player:hud_change(mana.playerlist[playername].hudid, "number", mana.get(playername))
|
end
|
||||||
end
|
|
||||||
|
function mana.hud_remove(playername)
|
||||||
function mana.hud_remove(playername)
|
local player = minetest.get_player_by_name(playername)
|
||||||
local player = minetest.get_player_by_name(playername)
|
player:hud_remove(mana.playerlist[playername].hudid)
|
||||||
player:hud_remove(mana.playerlist[playername].hudid)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user