Advertisement
Guest User

startup

a guest
Sep 2nd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. --Variables
  2. players = {"Setzes", "Timmae1999"}
  3. open = false
  4. x, y = term.getSize()
  5. os.pullEvent = os.pullEventRaw
  6.  
  7. --Functions
  8. function drawAcross(line, char)
  9.  term.setCursorPos(1, line)
  10.  for i = 1,  x do
  11.   term.write(char)
  12.  end
  13. end
  14.  
  15. function drawCentered(line, text)
  16.  term.setCursorPos((x - string.len(text))/ 2, line)
  17.  term.write(text)
  18. end
  19.  
  20. function openDoor()
  21.  rs.setOutput("bottom", true)
  22.  sleep(3.0)
  23.  rs.setOutput("bottom", false)
  24.  sleep(0.1)
  25. end
  26.  
  27. function soundAlarm()
  28.  rs.setOutput("top", true)
  29.  sleep(1.5)
  30.  rs.setOutput("top", false)
  31.  sleep(0.1)
  32. end
  33.  
  34. --Body code
  35. term.clear()
  36. drawAcross(1, "*")
  37. drawCentered(2, "Germania")
  38. drawCentered(3, "Central Security")
  39. drawAcross(4,"*")
  40. drawCentered(6, "Acces for: Setzes, Timmae1999")
  41. while true do
  42.  event, p1 = os.pullEvent()
  43.  
  44.  if event == "player" then
  45.   for i = 1, #players do
  46.    if players[i] == p1 then
  47.     openDoor()
  48.     open = true
  49.     end
  50.   end
  51.  
  52.   if not open then
  53.    soundAlarm()
  54.   end
  55.    
  56.  end
  57.  
  58.  if event == "redstone" then
  59.   openDoor()
  60.  end
  61.    
  62.  if (event == "key") and (p1 == 26) then
  63.   break
  64.  end
  65.  
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement