I created a program that should read player status from the sensor.
I start the program on a computer, and leave the area.
When I return, I will find that the program ends, with a line that say
programname:5: Entity not found
How can I better loop this, so that it'll only run s.getPlayerData("Phantom") when I'm in range, but will keep running even when no entities are in range?
Here is a quick example:
sensor = peripheral.wrap("right")
rs.setoutput("bottom",false)
while true do
local owner = sensor.getPlayerData("Phantom") -- Determine stranger danger or not...
if owner then
local hunger = sensor.getPlayerData("Phantom")["foodLevel"] -- getting hunger level
if hunger < 20 then
-- Code to spit out some food, then sleep for 15
else
rs.setoutput("bottom",false) -- Did this to make sure that my redstone signal returned to false
end
end
sleep(0)
end
If this has been answered before, I apologize, but I couldn't find any examples quite close enough to help me out using the sensor block.
Thank you!
**Edited to add code tags... my bad!
***Edited again for clarity.
Edited by PhantomOfTheRouter, 02 January 2015 - 04:53 AM.












