Advertisement
Jackson_Pike

Untitled

Jul 21st, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. ----Startup----
  2. local modem = peripheral.wrap("back")
  3.  
  4. termX, termY = term.getSize()
  5. modem.open(1)
  6. --------------
  7. function toggle()
  8.     modem.transmit(1, 1, "toggle")
  9. end
  10. event, modemSide, senderChannel, replyChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  11. if message == "UNLOCK" then
  12. LockScreen()
  13. end
  14. if message == "LOCK" then
  15. UnLockScreen()
  16. end
  17.  
  18. function LockScreen()
  19.     term.setBackgroundColor(colors.black)
  20.     term.clear()
  21.     term.setCursorPos(1, 1)
  22.     term.setBackgroundColor(colors.red)
  23.     term.write(string.rep(" ", termX))
  24.     term.setCursorPos(1, termY)
  25.     term.write(string.rep(" ", termY))
  26.     term.setBackgroundColor(colors.black)
  27.     term.setTextColor(colors.red)
  28.     term.setCursorPos(termX/2-3, 3)
  29.     term.write("Lock")
  30. end
  31. function UnlockScreen()
  32.     term.setBackgroundColor(colors.black)
  33.     term.clear()
  34.     term.setCursorPos(1, 1)
  35.     term.setBackgroundColor(colors.green)
  36.     term.write(string.rep(" ", termX))
  37.     term.setCursorPos(1, termY)
  38.     term.write(string.rep(" ", termX))
  39.     term.setBackgroundColor(colors.black)
  40.     term.setTextColor(colors.green)
  41.     term.setCursorPos(10, 4)
  42.     term.write("Unlock")  
  43. end
  44. --------------
  45. event, side, xpos, ypos = os.pullEvent("mouse_click")
  46. -------------------------
  47. --math = termX/2-3
  48. if xpos >= 10 and xpos <= 15 and ypos == 4 then
  49.  
  50.  toggle()
  51.  LockScreen()
  52. end
  53. if xpos >= 11 and xpos <= 14 and ypos == 5 then
  54.    toggle()
  55.    UnlockScreen()
  56. end
  57.  
  58. event, modemSide, senderChannel, replyChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  59. if message == "UNLOCK" then
  60. LockScreen()
  61. end
  62. if message == "LOCK" then
  63. UnLockScreen()
  64. end
  65. sleep(0.1)
  66. shell.run("startup")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement