Add setting use_hud, used to control player HUDs

This commit is contained in:
Wuzzy 2014-07-13 21:57:45 +02:00
parent 25fcabc095
commit bf50528228
2 changed files with 56 additions and 38 deletions

View File

@ -18,6 +18,9 @@ playereffects.inactive_effects = {}
-- Variable for counting the effect_id
playereffects.last_effect_id = 0
--[=[ Include settings ]=]
dofile(minetest.get_modpath("playereffects").."/settings.lua")
--[=[ Load inactive_effects and last_effect_id from playereffects.mt, if this file exists ]=]
do
local filepath = minetest.get_worldpath().."/playereffects.mt"
@ -270,6 +273,7 @@ end)
--[=[ HUD ]=]
function playereffects.hud_update(player)
if(playereffects.use_hud == true) then
local now = os.time()
local effects = playereffects.get_player_effects(player:get_player_name())
for e=1,#effects do
@ -281,8 +285,10 @@ function playereffects.hud_update(player)
end
end
end
end
function playereffects.hud_clear(player)
if(playereffects.use_hud == true) then
local playername = player:get_player_name()
local effects = playereffects.get_player_effects(playername)
if(effects ~= nil) then
@ -296,9 +302,11 @@ function playereffects.hud_clear(player)
end
end
end
end
function playereffects.hud_effect(effect_type_id, player, pos, time_left)
local text_id, icon_id
if(playereffects.use_hud == true) then
text_id = player:hud_add({
hud_elem_type = "text",
position = { x = 1, y = 0.3 },
@ -322,6 +330,10 @@ function playereffects.hud_effect(effect_type_id, player, pos, time_left)
offset = { x = -186, y = pos*20 },
})
end
else
text_id = nil
icon_id = nil
end
return { text_id = text_id, icon_id = icon_id }
end

6
settings.lua Normal file
View File

@ -0,0 +1,6 @@
--[[
Settings for Player Effects
]]
-- Wheather to use the HUD to expose the active effects to players (true or false)
playereffects.use_hud = true