Jackson_Pike icon

transmitterv2.lua

Jackson_Pike | PRO | 07/21/17 11:25:05 AM UTC | 0 ⭐ | 271 👁️ | Never ⏰ | []
Lua |

1.31 KB

|

None

|

0 👍

/

0 👎

----Startup----
local modem = peripheral.wrap("back")
 
termX, termY = term.getSize()
modem.open(1)
--------------
function toggle()
    modem.transmit(1, 1, "toggle")
end
 
function LockScreen()
    term.setBackgroundColor(colors.black)
    term.clear()
    term.setCursorPos(1, 1)
    term.setBackgroundColor(colors.red)
    term.write(string.rep(" ", termX))
    term.setCursorPos(1, termY)
    term.write(string.rep(" ", termY))
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.red)
    term.setCursorPos(termX/2-3, 3)
    term.write("Lock")
end
function UnlockScreen()
    term.setBackgroundColor(colors.black)
    term.clear()
    term.setCursorPos(1, 1)
    term.setBackgroundColor(colors.green)
    term.write(string.rep(" ", termX))
    term.setCursorPos(1, termY)
    term.write(string.rep(" ", termY))
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.green)
    term.setCursorPos(termX/2-3, 3)
    term.write("Unlock")    
end
--------------
event, side, xpos, ypos = os.pullEvent("mouse_click")
-------------------------
if event == "mouse_click" then
 toggle()
end
event, modemSide, senderChannel, replyChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
if message == "UNLOCK" then
LockScreen()
end
if message == "LOCK" then
UnLockScreen()
end
sleep(0.1)
shell.run("startup")

Comments