Advertisement
honeyphos1234

Player detector door lock

Jun 22nd, 2015
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. --Put a howler alarm on top of the computer if possible and u want an alarm
  2. --also do 'edit startup'
  3. --then put 'shell.run("program name")
  4.  
  5. players = {'player username goes here'}
  6. pd = peripheral.wrap("Back") --player detector
  7. text = 'Security Systems v2.1'
  8. textLen = string.len(text)
  9. tX, tY = term.getSize()
  10.  
  11. os.pullEvent = os.pullEventRaw --makes it so that u can't terminate the computer
  12. --functions
  13. function openDoor()
  14.  rs.setOutput("bottom", true)
  15.  sleep(3)
  16.  rs.setOuput("bottom", false)
  17.  sleep(0.1)
  18. end
  19.  
  20. function alarm()
  21.  redstoneOuput("top", true)
  22.  sleep(2)
  23.  redstoneOutput("top", false)
  24.  sleep(0.1)
  25. end
  26.  
  27.   function drawLine(char)
  28.    for x = 1, tX
  29.     term.setCursorPos(1, 1)
  30.     term.write(char)
  31.    end
  32.    Term.setCursorPos(tX/2-textLen, 2)
  33.    Term.write(text)
  34.    term.setCursorPos(3, 1)
  35.    for x = 1, tX
  36.     term.write(char)
  37.    end
  38.   end
  39.  
  40. drawLine('*')
  41.  
  42. while true do
  43.  event, p1 = os.pullEvent
  44.  if event = "key" then
  45.   if p1 = '16' then --Q key quits change the number only if u know
  46.    break
  47.   end
  48.  end
  49.  if event = "player"  then
  50.   for p = 1, #players
  51.    if p1 = players[p] then
  52.     openDoor()
  53.    end
  54.   end
  55.  if event = "redstone" then
  56.   openDoor()
  57.  end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement