Jackson_Pike

transmitterv2.lua

Jul 21st, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 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.  
  11. function LockScreen()
  12.     term.setBackgroundColor(colors.black)
  13.     term.clear()
  14.     term.setCursorPos(1, 1)
  15.     term.setBackgroundColor(colors.red)
  16.     term.write(string.rep(" ", termX))
  17.     term.setCursorPos(1, termY)
  18.     term.write(string.rep(" ", termY))
  19.     term.setBackgroundColor(colors.black)
  20.     term.setTextColor(colors.red)
  21.     term.setCursorPos(termX/2-3, 3)
  22.     term.write("Lock")
  23. end
  24. function UnlockScreen()
  25.     term.setBackgroundColor(colors.black)
  26.     term.clear()
  27.     term.setCursorPos(1, 1)
  28.     term.setBackgroundColor(colors.green)
  29.     term.write(string.rep(" ", termX))
  30.     term.setCursorPos(1, termY)
  31.     term.write(string.rep(" ", termY))
  32.     term.setBackgroundColor(colors.black)
  33.     term.setTextColor(colors.green)
  34.     term.setCursorPos(termX/2-3, 3)
  35.     term.write("Unlock")   
  36. end
  37. --------------
  38. event, side, xpos, ypos = os.pullEvent("mouse_click")
  39. -------------------------
  40. if event == "mouse_click" then
  41.  toggle()
  42. end
  43. event, modemSide, senderChannel, replyChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  44. if message == "UNLOCK" then
  45. LockScreen()
  46. end
  47. if message == "LOCK" then
  48. UnLockScreen()
  49. end
  50. sleep(0.1)
  51. shell.run("startup")
Advertisement
Add Comment
Please, Sign In to add comment