diff --git a/moremesecons_playerkiller/init.lua b/moremesecons_playerkiller/init.lua index 216918d..beb4efe 100644 --- a/moremesecons_playerkiller/init.lua +++ b/moremesecons_playerkiller/init.lua @@ -6,8 +6,7 @@ local kill_nearest_player = function(pos) local min_distance = MAX_DISTANCE for index, player in pairs(minetest.get_connected_players()) do local distance = vector.distance(pos, player:getpos()) - if distance < MAX_DISTANCE - and distance < min_distance then + if distance < min_distance then min_distance = distance nearest = player end @@ -23,6 +22,11 @@ local kill_nearest_player = function(pos) -- maybe some mod placed it return end + + if owner == nearest:get_player_name() then + -- don't kill the owner ! + return + end -- And kill him nearest:set_hp(0) diff --git a/moremesecons_teleporter/init.lua b/moremesecons_teleporter/init.lua index 67529c2..b501a2e 100644 --- a/moremesecons_teleporter/init.lua +++ b/moremesecons_teleporter/init.lua @@ -11,11 +11,12 @@ local register = function(pos) end local teleport_nearest = function(pos) - local MAX_DISTANCE = 50 + local MAX_TELEPORTATION_DISTANCE = 50 + local MAX_PLAYER_DISTANCE = 25 -- Search the nearest player local nearest = nil - local min_distance = math.huge + local min_distance = MAX_PLAYER_DISTANCE local players = minetest.get_connected_players() for index, player in pairs(players) do local distance = vector.distance(pos, player:getpos()) @@ -25,6 +26,11 @@ local teleport_nearest = function(pos) end end + if not nearest then + -- If there is no nearest player (maybe too far...) + return + end + -- Search other teleporter and teleport if not minetest.registered_nodes["moremesecons_teleporter:teleporter"] then return end @@ -41,7 +47,10 @@ local teleport_nearest = function(pos) end end if newpos.x then - if vector.distance(newpos, nearest:getpos()) > MAX_DISTANCE then newpos = {} end -- If the is another teleporter BUT too far, delete newpos. + -- If there is another teleporter BUT too far, delete newpos. + if vector.distance(newpos, pos) > MAX_TELEPORTATION_DISTANCE then + newpos = {} + end end if not newpos.x then newpos = {x=pos.x, y=pos.y+1, z=pos.z} -- If newpos doesn't exist, teleport on the actual teleporter.