2018-10-15 17:24:58 +02:00
|
|
|
hud_ids = {}
|
|
|
|
|
2018-10-17 04:58:15 +02:00
|
|
|
function createHudfactionLand(player)
|
2018-10-28 04:37:49 +01:00
|
|
|
if player then
|
|
|
|
local name = player:get_player_name()
|
|
|
|
local id_name = name .. "factionLand"
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-28 04:37:49 +01:00
|
|
|
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},
|
2019-01-26 07:21:05 +01:00
|
|
|
text = "Parcel:",
|
2018-10-28 04:37:49 +01:00
|
|
|
scale = {x=1, y=1},
|
|
|
|
alignment = {x=0, y=0},
|
|
|
|
})
|
|
|
|
end
|
2018-10-28 02:06:48 +01:00
|
|
|
end
|
2018-10-15 17:24:58 +02:00
|
|
|
end
|
|
|
|
|
2019-01-26 07:21:05 +01:00
|
|
|
function createHudFactionName(player, factionname)
|
2018-10-28 04:37:49 +01:00
|
|
|
if player and factionname then
|
|
|
|
local name = player:get_player_name()
|
|
|
|
local id_name = name .. "factionName"
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-28 04:37:49 +01:00
|
|
|
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},
|
2019-01-26 07:21:05 +01:00
|
|
|
text = "Faction " .. factionname,
|
2018-10-28 04:37:49 +01:00
|
|
|
scale = {x=1, y=1},
|
|
|
|
alignment = {x=-1, y=0},
|
|
|
|
offset = {x = -20, y = 20}
|
|
|
|
})
|
|
|
|
end
|
2018-10-15 17:24:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-26 07:21:05 +01:00
|
|
|
function createHudPower(player, faction)
|
2018-10-28 04:37:49 +01:00
|
|
|
if player and faction then
|
|
|
|
local name = player:get_player_name()
|
|
|
|
local id_name = name .. "powerWatch"
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-28 04:37:49 +01:00
|
|
|
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},
|
2019-01-26 07:21:05 +01:00
|
|
|
text = "Power: " .. faction.power .. " / " .. faction.maxpower - faction.usedpower,
|
2018-10-28 04:37:49 +01:00
|
|
|
scale = {x=1, y=1},
|
|
|
|
alignment = {x=-1, y=0},
|
|
|
|
offset = {x = 0, y = 0}
|
|
|
|
})
|
|
|
|
end
|
2018-10-15 17:24:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-26 07:21:05 +01:00
|
|
|
function removeHud(player, hudname)
|
2018-10-31 22:15:08 +01:00
|
|
|
local name = ""
|
|
|
|
local p = {}
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-31 22:15:08 +01:00
|
|
|
if type(player) ~= "string" then
|
|
|
|
name = player:get_player_name()
|
|
|
|
p = player
|
|
|
|
else
|
|
|
|
name = player
|
|
|
|
p = minetest.get_player_by_name(player)
|
|
|
|
end
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-31 22:15:08 +01:00
|
|
|
local id_name = name .. hudname
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-31 22:15:08 +01:00
|
|
|
if hud_ids[id_name] then
|
|
|
|
p:hud_remove(hud_ids[id_name])
|
|
|
|
hud_ids[id_name] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-26 07:21:05 +01:00
|
|
|
function updateHudPower(player, faction)
|
2018-10-15 17:24:58 +02:00
|
|
|
local name = player:get_player_name()
|
|
|
|
local id_name = name .. "powerWatch"
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-15 17:24:58 +02:00
|
|
|
if hud_ids[id_name] then
|
2019-01-26 07:21:05 +01:00
|
|
|
player:hud_change(hud_ids[id_name], "text", "Power: " .. faction.power .. " / " .. faction.maxpower - faction.usedpower)
|
2018-10-15 17:24:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-26 07:21:05 +01:00
|
|
|
function updateFactionName(player, factionname)
|
2018-10-22 21:30:11 +02:00
|
|
|
local name = ""
|
|
|
|
local p = {}
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-22 21:30:11 +02:00
|
|
|
if type(player) ~= "string" then
|
|
|
|
name = player:get_player_name()
|
|
|
|
p = player
|
|
|
|
else
|
|
|
|
name = player
|
|
|
|
p = minetest.get_player_by_name(player)
|
|
|
|
end
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-31 22:15:08 +01:00
|
|
|
local id_name = name .. "factionName"
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-15 17:24:58 +02:00
|
|
|
if hud_ids[id_name] then
|
2019-01-26 07:21:05 +01:00
|
|
|
p:hud_change(hud_ids[id_name], "text", "Faction " .. factionname)
|
2018-10-15 17:24:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-17 04:58:15 +02:00
|
|
|
function hudUpdateClaimInfo()
|
2018-10-27 22:40:17 +02:00
|
|
|
local playerslist = minetest.get_connected_players()
|
|
|
|
for i in pairs(playerslist) do
|
|
|
|
local player = playerslist[i]
|
|
|
|
local name = player:get_player_name()
|
2019-01-26 07:21:05 +01:00
|
|
|
local faction, facname = factions.get_faction_at(player:getpos())
|
2018-10-27 22:40:17 +02:00
|
|
|
local id_name = name .. "factionLand"
|
2019-01-26 07:21:05 +01:00
|
|
|
|
2018-10-27 22:40:17 +02:00
|
|
|
if hud_ids[id_name] then
|
2019-01-26 07:21:05 +01:00
|
|
|
local display = "Parcel:"
|
|
|
|
if facname then
|
|
|
|
display = display .. facname
|
|
|
|
end
|
|
|
|
player:hud_change(hud_ids[id_name], "text", display)
|
2018-10-15 17:24:58 +02:00
|
|
|
end
|
2018-10-27 22:40:17 +02:00
|
|
|
end
|
2019-01-26 07:21:05 +01:00
|
|
|
minetest.after(3, hudUpdateClaimInfo)
|
2018-10-15 17:24:58 +02:00
|
|
|
end
|