Posted 06 July 2014 - 05:45 AM
I am attempting to use ccSensors to detect a player, because I want to reference said player's name in a program. My goal is to have a computer output a redstone signal when either my friend or I come close to the sensor. I am using CC CraftOS 1.3. All I could find on the ccSensors version was 'version: MC1.2.5 Build017pr1'. The code I have I'm using to attempt to find a way to reference the player name from the probe data.
Also, going one step beyond this. How would I reference this in the program to open a door based on what player is around. A baseline for my code would be something like this. But I still have no clue how to reference the probe for player's name because it's returning a table.
os.unloadAPI("sensors")
os.loadAPI("/rom/apis/sensors")
function printDict(data)
for i,v in pairs(data) do
print(tostring(i).." - "..tostring(v))
end
end
data = sensors.getSensorReadingAsDict("left", "playerSensor", "vq", "Players.name")
print(data)
The problem i'm running into right now is it's returning a table, not a dictionary. It returns the value 'table: 1b0782c7'. Is there any way to convert this table to a word, for example the player's name.Also, going one step beyond this. How would I reference this in the program to open a door based on what player is around. A baseline for my code would be something like this. But I still have no clue how to reference the probe for player's name because it's returning a table.
local side = "left"
local opentime = 5
while true do
trusted = matt2887, Agnistu
if sensors.getSensorReadingAsDict("left", "playerSensor", "vq", "Players.name") == trusted then
rs.setOutput(side, true)
sleep(opentime)
rs.setOutput(side, false)
end
end
Edited on 06 July 2014 - 03:48 AM