Advertisement
CryptekCoding

Untitled

Jun 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. local component = component or require("component")
  2. local computer = computer or require("computer")
  3.  
  4. local user = { "TheCryptek", "user2", "user3" }
  5.  
  6. local red = component.proxy(component.list("redstone")())
  7. local scr = {}
  8. local gpu = {}
  9.  
  10. for a in component.list("screen") do table.insert(scr, a) end
  11. for a in component.list("gpu") do table.insert(gpu, component.proxy(a)) end
  12. for i = 1, #gpu do gpu[i].bind(scr[i]) end
  13.  
  14. function showState(s)
  15. for i, g in ipairs(gpu) do
  16. g.setResolution(40, 20)
  17. g.fill(1, 1, 40, 20, " ")
  18. if s then
  19. g.setForeground(0x00FF00)
  20. g.set(16, 10, "Access denied")
  21. else
  22. g.setForeground(0xFF0000)
  23. g.set(16, 10, "Access granted")
  24. end
  25. end
  26. end
  27.  
  28. function sleep(x)
  29. local tgt = computer.uptime() + x
  30. while computer.uptime() < tgt do
  31. computer.pullSignal(tgt - computer.uptime())
  32. end
  33. end
  34.  
  35. while true do
  36. showState(false)
  37. local type, _, x, y, btn, nick = computer.pullSignal(5)
  38. if type == "touch" then
  39. nick = nick:lower()
  40. for i, v in ipairs(user) do
  41. if v == nick then
  42. showState(true)
  43. red.setOutput(1, 255)
  44. sleep(2)
  45. red.setOutput(1, 0)
  46. end
  47. end
  48. end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement