mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 02:00:37 +01:00
[u_inv] Move part of item_name's globalstep into a step function
- For #179
This commit is contained in:
parent
72a9dc14dc
commit
216cec300e
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
local wield = {}
|
local wield = {}
|
||||||
local huds = {}
|
local huds = {}
|
||||||
local dtimes = {}
|
|
||||||
local dlimit = 3 -- HUD element will be hidden after this many seconds
|
local dlimit = 3 -- HUD element will be hidden after this many seconds
|
||||||
local air_hud_mod = minetest.get_modpath("4air")
|
local air_hud_mod = minetest.get_modpath("4air")
|
||||||
local hud_mod = minetest.get_modpath("hud")
|
local hud_mod = minetest.get_modpath("hud")
|
||||||
@ -25,23 +24,24 @@ end
|
|||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
minetest.after(0, set_hud, player)
|
minetest.after(0, set_hud, player)
|
||||||
|
minetest.after(dlimit, u_inv_hud_step, player:get_player_name())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
function u_inv_hud_step(name)
|
||||||
|
local p = minetest.get_player_by_name(name)
|
||||||
|
if not p then return end
|
||||||
|
|
||||||
|
p:hud_change(huds[name], 'text', "")
|
||||||
|
minetest.after(dlimit, u_inv_hud_step, name)
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local wstack = player:get_wielded_item():get_name()
|
local wstack = player:get_wielded_item():get_name()
|
||||||
|
|
||||||
if dtimes[player_name] and dtimes[player_name] < dlimit then
|
|
||||||
dtimes[player_name] = dtimes[player_name] + dtime
|
|
||||||
if dtimes[player_name] > dlimit and huds[player_name] then
|
|
||||||
player:hud_change(huds[player_name], 'text', "")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if wstack ~= wield[player_name] then
|
if wstack ~= wield[player_name] then
|
||||||
wield[player_name] = wstack
|
wield[player_name] = wstack
|
||||||
dtimes[player_name] = 0
|
|
||||||
if huds[player_name] then
|
if huds[player_name] then
|
||||||
local def = minetest.registered_items[wstack]
|
local def = minetest.registered_items[wstack]
|
||||||
local desc = def and def.description or ""
|
local desc = def and def.description or ""
|
||||||
|
Loading…
Reference in New Issue
Block a user