Change the code a bit

This commit is contained in:
paly2
2015-09-04 17:58:37 +02:00
parent 708c8b045a
commit 419fa62656
2 changed files with 18 additions and 5 deletions

View File

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