353 posts
Location
Orewa, New Zealand
Posted 30 June 2014 - 03:24 AM
I have a tunnel system which has several bulkheads which close when I issue their closure through a PDA, although I want a alarm that detects intruders and send the signal to the master computer, I can handle the rednet stuff if someone can help me code a device to check who the sensor detects, I'm playing the mindcrack crackpack and I think the sensor is from opens peripherals addon… I don't know where to start
I understand this isn't somewhere for people to give code but your time will be greatly appreciated.
7083 posts
Location
Tasmania (AU)
Posted 30 June 2014 - 03:33 AM
You'll first want to determine how to use the peripheral.
This guide should teach you how to figure that out.
If the device is a recentish OpenPeripheral block, you may also be able to get further information about the commands it grants you by entering into the prompt:
openp/docs <side> <methodname>
353 posts
Location
Orewa, New Zealand
Posted 30 June 2014 - 06:34 AM
… That doesnt help, I know how to use peripherals its just the tables and stuff i dont understand
7083 posts
Location
Tasmania (AU)
Posted 30 June 2014 - 07:19 AM
105 posts
Posted 30 June 2014 - 10:24 AM
You can use sensor.getPlayerNames() (Ofcourse sensor. would be your wrap for the peripheral)
This will reutrn a table of all people withing sensor range. Then this way you can loop through them:
for i,player in pairs(sensor.getPlayerNames) do
end
Then to check whether or not he is an intruder you could set up a whitelist using a table
whitelist={
["playerName"]=true,
["anoterName"]=true,
["nameyName"]=true,
}
function checkPlayers()
for id,player in pairs(sensor.getPlayerNames) do
if not whitelist[player] then
--Your code to sound the alarm
end
end
end