LifeSensor - iimurpyh/pilot-lua GitHub Wiki

A device which senses life in a region. It is used to get players and their positions in the local region. Lifesensors are mostly useful in turrets and player-seeking missiles.

Table of contents

Methods


dictionary LifeSensor:GetReading()

Gets the life in the local region. Returns a dictionary where each key is the name of a player, and each value is their position in the world. Has a range of 2000 studs.

An example of the format can be seen below:

{
 [string PLAYER_NAME] = Vector3 VECTOR3_POSITION;
 ...
}

where PLAYER_NAME is the player's name, and VECTOR3_POSITION is the position of the player

Code examples

  • We print out the dictionary every 30 seconds.
local lifesensor = GetPartFromPort(1, "LifeSensor")

while true do
  print(JSONEncode(lifesensor:GetReading()))
  task.wait(30)
end