mirror of
https://repo.or.cz/minetest_playereffects.git
synced 2025-01-10 02:50:18 +01:00
Add setting use_hud, used to control player HUDs
This commit is contained in:
parent
25fcabc095
commit
bf50528228
12
init.lua
12
init.lua
@ -18,6 +18,9 @@ playereffects.inactive_effects = {}
|
|||||||
-- Variable for counting the effect_id
|
-- Variable for counting the effect_id
|
||||||
playereffects.last_effect_id = 0
|
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 ]=]
|
--[=[ Load inactive_effects and last_effect_id from playereffects.mt, if this file exists ]=]
|
||||||
do
|
do
|
||||||
local filepath = minetest.get_worldpath().."/playereffects.mt"
|
local filepath = minetest.get_worldpath().."/playereffects.mt"
|
||||||
@ -270,6 +273,7 @@ end)
|
|||||||
|
|
||||||
--[=[ HUD ]=]
|
--[=[ HUD ]=]
|
||||||
function playereffects.hud_update(player)
|
function playereffects.hud_update(player)
|
||||||
|
if(playereffects.use_hud == true) then
|
||||||
local now = os.time()
|
local now = os.time()
|
||||||
local effects = playereffects.get_player_effects(player:get_player_name())
|
local effects = playereffects.get_player_effects(player:get_player_name())
|
||||||
for e=1,#effects do
|
for e=1,#effects do
|
||||||
@ -281,8 +285,10 @@ function playereffects.hud_update(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function playereffects.hud_clear(player)
|
function playereffects.hud_clear(player)
|
||||||
|
if(playereffects.use_hud == true) then
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local effects = playereffects.get_player_effects(playername)
|
local effects = playereffects.get_player_effects(playername)
|
||||||
if(effects ~= nil) then
|
if(effects ~= nil) then
|
||||||
@ -296,9 +302,11 @@ function playereffects.hud_clear(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function playereffects.hud_effect(effect_type_id, player, pos, time_left)
|
function playereffects.hud_effect(effect_type_id, player, pos, time_left)
|
||||||
local text_id, icon_id
|
local text_id, icon_id
|
||||||
|
if(playereffects.use_hud == true) then
|
||||||
text_id = player:hud_add({
|
text_id = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = { x = 1, y = 0.3 },
|
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 },
|
offset = { x = -186, y = pos*20 },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
text_id = nil
|
||||||
|
icon_id = nil
|
||||||
|
end
|
||||||
return { text_id = text_id, icon_id = icon_id }
|
return { text_id = text_id, icon_id = icon_id }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
6
settings.lua
Normal file
6
settings.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user