2016-08-27 08:44:17 +02:00
|
|
|
local playerUtils = {}
|
|
|
|
|
|
|
|
-- imports
|
|
|
|
|
2017-06-16 03:30:26 +02:00
|
|
|
local mathUtils = require("MathUtils")
|
2016-08-27 08:44:17 +02:00
|
|
|
|
|
|
|
-- imported functions
|
|
|
|
|
2017-06-16 03:30:26 +02:00
|
|
|
local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
|
2016-08-27 08:44:17 +02:00
|
|
|
|
|
|
|
-- module code
|
|
|
|
|
2017-05-19 09:47:24 +02:00
|
|
|
function playerUtils.validPlayer(player)
|
|
|
|
return (player ~= nil) and player.connected and (player.character ~= nil) and player.character.valid and (player.character.surface.index == 1)
|
|
|
|
end
|
|
|
|
|
2016-08-27 08:44:17 +02:00
|
|
|
function playerUtils.playersWithinProximityToPosition(players, position, distance)
|
2016-10-15 02:00:18 +02:00
|
|
|
for _,player in pairs(players) do
|
|
|
|
if (player ~= nil) and player.connected and (player.character ~= nil) and player.character.valid and (player.character.surface.index == 1) then
|
|
|
|
if (euclideanDistanceNamed(player.character.position, position) < distance) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2016-08-27 08:44:17 +02:00
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-10-15 02:00:18 +02:00
|
|
|
return playerUtils
|