forked from mtcontrib/factions
Updated on_dieplayer and HUD update to newer API
This commit is contained in:
parent
685855e681
commit
4c72e388e8
14
factions.lua
14
factions.lua
@ -495,17 +495,19 @@ function factions.get_parcel_pos(pos)
|
|||||||
return math.floor(pos.x / 16.)..","..math.floor(pos.z / 16.)
|
return math.floor(pos.x / 16.)..","..math.floor(pos.z / 16.)
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.get_player_faction(payername)
|
function factions.get_player_faction(playername)
|
||||||
local facname = factions.players[playername]
|
local facname = factions.players[playername]
|
||||||
if facname then
|
if facname then
|
||||||
|
minetest.chat_send_all(facname)
|
||||||
local faction = factions.factions[facname]
|
local faction = factions.factions[facname]
|
||||||
return faction
|
return faction
|
||||||
end
|
end
|
||||||
|
minetest.chat_send_all(playername)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.get_parcel_faction(parcelpos)
|
function factions.get_parcel_faction(parcelpos)
|
||||||
local facname = factions.parcels[playername]
|
local facname = factions.parcels[parcelpos]
|
||||||
if facname then
|
if facname then
|
||||||
local faction = factions.factions[facname]
|
local faction = factions.factions[facname]
|
||||||
return faction
|
return faction
|
||||||
@ -670,11 +672,10 @@ end
|
|||||||
|
|
||||||
minetest.register_on_dieplayer(
|
minetest.register_on_dieplayer(
|
||||||
function(player)
|
function(player)
|
||||||
local faction = factions.players[player:get_player_name()]
|
local faction = factions.get_player_faction(player:get_player_name())
|
||||||
if not faction then
|
if not faction then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
faction = factions.factions[faction]
|
|
||||||
faction:decrease_power(factions.power_per_death)
|
faction:decrease_power(factions.power_per_death)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -701,15 +702,14 @@ minetest.register_globalstep(
|
|||||||
local playerslist = minetest.get_connected_players()
|
local playerslist = minetest.get_connected_players()
|
||||||
for i in pairs(playerslist) do
|
for i in pairs(playerslist) do
|
||||||
local player = playerslist[i]
|
local player = playerslist[i]
|
||||||
local parcelpos = factions.get_parcel_pos(player:getpos())
|
local faction = factions.get_faction_at(player:getpos())
|
||||||
local faction = factions.parcels[parcelpos]
|
|
||||||
player:hud_remove("factionLand")
|
player:hud_remove("factionLand")
|
||||||
player:hud_add({
|
player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
name = "factionLand",
|
name = "factionLand",
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
position = {x=0.1, y = .98},
|
position = {x=0.1, y = .98},
|
||||||
text = faction or "Wilderness",
|
text = (faction and faction.name) or "Wilderness",
|
||||||
scale = {x=1, y=1},
|
scale = {x=1, y=1},
|
||||||
alignment = {x=0, y=0},
|
alignment = {x=0, y=0},
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user