Delay for 5 seconds on all hud.

This commit is contained in:
Coder12a 2018-10-27 22:37:49 -05:00
parent 146df88de2
commit 615c9464cc
2 changed files with 47 additions and 41 deletions

View File

@ -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

82
hud.lua
View File

@ -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