Allow: is_protected to work without player param

This commit is contained in:
Coder12a 2019-05-24 14:40:58 -05:00
parent 7fa6abd4aa
commit c8f3528a43
3 changed files with 22 additions and 21 deletions

View File

@ -4,8 +4,7 @@ minetest.register_on_prejoinplayer(function(name, ip)
factions.player_ips.set(name, ip) factions.player_ips.set(name, ip)
end) end)
minetest.register_on_joinplayer( minetest.register_on_joinplayer(function(player)
function(player)
local name = player:get_player_name() local name = player:get_player_name()
minetest.after(5, createHudfactionLand, player) minetest.after(5, createHudfactionLand, player)
local faction, facname = factions.get_player_faction(name) local faction, facname = factions.get_player_faction(name)
@ -40,8 +39,7 @@ function(player)
end end
) )
minetest.register_on_leaveplayer( minetest.register_on_leaveplayer(function(player)
function(player)
local name = player:get_player_name() local name = player:get_player_name()
local faction, facname = factions.get_player_faction(name) local faction, facname = factions.get_player_faction(name)
local id_name1 = name .. "factionLand" local id_name1 = name .. "factionLand"
@ -69,8 +67,7 @@ minetest.register_on_leaveplayer(
end end
) )
minetest.register_on_respawnplayer( minetest.register_on_respawnplayer(function(player)
function(player)
local name = player:get_player_name() local name = player:get_player_name()
local faction, facname = factions.get_player_faction(name) local faction, facname = factions.get_player_faction(name)
@ -88,8 +85,7 @@ minetest.register_on_respawnplayer(
end end
) )
minetest.register_on_dieplayer( minetest.register_on_dieplayer(function(player)
function(player)
local pname = player:get_player_name() local pname = player:get_player_name()
if on_death[pname] then if on_death[pname] then
return return

View File

@ -9,7 +9,11 @@ minetest.is_protected = function(pos, player)
local parcelpos = factions.get_parcel_pos(pos) local parcelpos = factions.get_parcel_pos(pos)
local parcel_faction, parcel_fac_name = factions.get_parcel_faction(parcelpos) local parcel_faction, parcel_fac_name = factions.get_parcel_faction(parcelpos)
local player_faction, player_fac_name = factions.get_player_faction(player) local player_faction
local player_fac_name
if player then
player_faction, player_fac_name = factions.get_player_faction(player)
end
-- no faction -- no faction
if not parcel_faction then if not parcel_faction then
@ -33,4 +37,5 @@ minetest.is_protected = function(pos, player)
else else
return true return true
end end
return false
end end