Posted 21 January 2013 - 07:10 AM
Hey,
I've got a little program that I wrote that uses a MiscPeripherals player detector to check whether I was the one who used the detector and if so, activate some redstone. Also, regardless of who used the detector, it sends a log with the player's name to a listener program on a different computer.
However, the issue i've been experiencing is is that when setting the redstone on, waiting 3 seconds then turning it off, the 'client' computer sends another log with data 'nil' to the listener computer when the redstone is turned off. After taking away the redstone code, I can see that it is the redstone that is causing the problem.
Here's the code:
Any help would be greatly appreciated. Also, on a fairly unrelated note, if there are other events such as keypresses, it sends the ID of that key to the listener. Is there a way to only accept event data from the player detector?
Thanks,
I've got a little program that I wrote that uses a MiscPeripherals player detector to check whether I was the one who used the detector and if so, activate some redstone. Also, regardless of who used the detector, it sends a log with the player's name to a listener program on a different computer.
However, the issue i've been experiencing is is that when setting the redstone on, waiting 3 seconds then turning it off, the 'client' computer sends another log with data 'nil' to the listener computer when the redstone is turned off. After taking away the redstone code, I can see that it is the redstone that is causing the problem.
Here's the code:
-- Player Detecting Test
local outputSide = "back" -- Side to output redstone signal to.
local logServerID = 3 -- Logging Server ID. Can be found by running 'id'.
local redn = rednet.open("left")
function checkPlayer()
print("Welcome. Please provide identification.")
local pla2, playerName23 = os.pullEvent(player)
print(playerName23)
rednet.send(logServerID,tostring(playerName23))
if playerName23 == "maccyjam" then
redstone.setOutput("back",true)
sleep(2)
redstone.setOutput("back",false)
end
checkPlayer()
end
checkPlayer()
Any help would be greatly appreciated. Also, on a fairly unrelated note, if there are other events such as keypresses, it sends the ID of that key to the listener. Is there a way to only accept event data from the player detector?
Thanks,