Added hud_change mod

master
Diego Martínez 2013-04-24 09:34:10 -03:00
parent 0d2c80ded0
commit 1d1bbf5102
1 changed files with 40 additions and 0 deletions

40
hud_change/init.lua Normal file
View File

@ -0,0 +1,40 @@
local hud_abbrevs = {
o = "hotbar";
h = "healthbar";
c = "crosshair";
w = "wielditem";
};
local function hud_set ( name, params, flag )
local p = minetest.env:get_player_by_name(name);
if (not p) then
print("hud_set: wut");
return;
end
for i = 1, params:len() do
local elem = hud_abbrevs[params:sub(i, i)];
if (elem) then
p:hud_builtin_enable(elem, flag);
end
end
end
minetest.register_chatcommand("hudset", {
params = "<hudstring>";
description = "h'o'tbar,'h'ealthbar,'c'rosshair,'w'ielditem";
func = function ( name, params )
hud_set(name, params, true);
end;
});
minetest.register_chatcommand("hudunset", {
params = "<hudstring>";
description = "h'o'tbar,'h'ealthbar,'c'rosshair,'w'ielditem";
func = function ( name, params )
hud_set(name, params, false);
end;
});