Posted 15 November 2016 - 11:29 AM
So, as the title suggests, I am trying to detect players around a sensor, and retrieve the name and relative position of the player. However, I am having a bit of trouble with the sensor's
getPlayers()
and
getPlayerByName()
functions. I use the first to get the list of players, but because of testing, I can just index the first element, as there will be only one player, which works out fine. Then I use that name in the second function to try to get some more precise information about that player, but this function just returns a table of functions as elements, as I have found by trying to print the keys and values. Here's the exact test code I have:
local p = peripheral.wrap("back")
local name = p.getPlayers()[1].name
local data = p.getPlayerByName(name)
for i in pairs(data) do
print(i)
end
The problem is, the output of that snippet is this:
listSources
getAdvancedMethodsData
all
listMethods
doc
keys
basic
select
single
How do I go from this list of methods to getting the relative position of the player, if I know their name?