Jump to content




Sensor Alarm


  • You cannot reply to this topic
4 replies to this topic

#1 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 30 June 2014 - 02: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.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 30 June 2014 - 02: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>


#3 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 30 June 2014 - 05:34 AM

... That doesnt help, I know how to use peripherals its just the tables and stuff i dont understand

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 30 June 2014 - 06:19 AM

Righto then.

#5 NanoBob

  • Members
  • 102 posts

Posted 30 June 2014 - 09: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






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users