From 615c9464cc8e1a5c10e2c46ad004d965644cb0c6 Mon Sep 17 00:00:00 2001 From: Coder12a <38924418+Coder12a@users.noreply.github.com> Date: Sat, 27 Oct 2018 22:37:49 -0500 Subject: [PATCH] Delay for 5 seconds on all hud. --- factions.lua | 6 ++-- hud.lua | 82 ++++++++++++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/factions.lua b/factions.lua index c4e0d2e..a7088fd 100644 --- a/factions.lua +++ b/factions.lua @@ -978,12 +978,12 @@ end minetest.register_on_joinplayer( function(player) local name = player:get_player_name() - minetest.after(5,function(player)createHudfactionLand(player)end,player) + minetest.after(5,createHudfactionLand,player) local faction = factions.get_player_faction(name) if faction then faction.last_logon = os.time() - createHudFactionName(player,faction.name) - createHudPower(player,faction) + minetest.after(5,createHudFactionName,player,faction.name) + minetest.after(5,createHudPower,player,faction) faction.offlineplayers[name] = nil faction.onlineplayers[name] = 1 if faction.no_parcel ~= -1 then diff --git a/hud.lua b/hud.lua index 8c97bda..82c7549 100644 --- a/hud.lua +++ b/hud.lua @@ -1,52 +1,58 @@ hud_ids = {} function createHudfactionLand(player) - local name = player:get_player_name() - local id_name = name .. "factionLand" - if not hud_ids[id_name] then - hud_ids[id_name] = player:hud_add({ - hud_elem_type = "text", - name = "factionLand", - number = 0xFFFFFF, - position = {x=0.1, y = .98}, - text = "Wilderness", - scale = {x=1, y=1}, - alignment = {x=0, y=0}, - }) + if player then + local name = player:get_player_name() + local id_name = name .. "factionLand" + if not hud_ids[id_name] then + hud_ids[id_name] = player:hud_add({ + hud_elem_type = "text", + name = "factionLand", + number = 0xFFFFFF, + position = {x=0.1, y = .98}, + text = "Wilderness", + scale = {x=1, y=1}, + alignment = {x=0, y=0}, + }) + end end end function createHudFactionName(player,factionname) - local name = player:get_player_name() - local id_name = name .. "factionName" - if not hud_ids[id_name] then - hud_ids[id_name] = player:hud_add({ - hud_elem_type = "text", - name = "factionName", - number = 0xFFFFFF, - position = {x=1, y = 0}, - text = "Faction "..factionname, - scale = {x=1, y=1}, - alignment = {x=-1, y=0}, - offset = {x = -20, y = 20} - }) + if player and factionname then + local name = player:get_player_name() + local id_name = name .. "factionName" + if not hud_ids[id_name] then + hud_ids[id_name] = player:hud_add({ + hud_elem_type = "text", + name = "factionName", + number = 0xFFFFFF, + position = {x=1, y = 0}, + text = "Faction "..factionname, + scale = {x=1, y=1}, + alignment = {x=-1, y=0}, + offset = {x = -20, y = 20} + }) + end end end function createHudPower(player,faction) - local name = player:get_player_name() - local id_name = name .. "powerWatch" - if not hud_ids[id_name] then - hud_ids[id_name] = player:hud_add({ - hud_elem_type = "text", - name = "powerWatch", - number = 0xFFFFFF, - position = {x=0.9, y = .98}, - text = "Power "..faction.power.."/".. faction.usedpower .."/"..faction.maxpower, - scale = {x=1, y=1}, - alignment = {x=-1, y=0}, - offset = {x = 0, y = 0} - }) + if player and faction then + local name = player:get_player_name() + local id_name = name .. "powerWatch" + if not hud_ids[id_name] then + hud_ids[id_name] = player:hud_add({ + hud_elem_type = "text", + name = "powerWatch", + number = 0xFFFFFF, + position = {x=0.9, y = .98}, + text = "Power "..faction.power.."/".. faction.usedpower .."/"..faction.maxpower, + scale = {x=1, y=1}, + alignment = {x=-1, y=0}, + offset = {x = 0, y = 0} + }) + end end end