----Startup----
local modem = peripheral.wrap("back")
termX, termY = term.getSize()
modem.open(1)
--------------
function toggle()
modem.transmit(1, 1, "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
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(" ", termX))
term.setBackgroundColor(colors.black)
term.setTextColor(colors.green)
term.setCursorPos(10, 4)
term.write("Unlock")
end
--------------
event, side, xpos, ypos = os.pullEvent("mouse_click")
-------------------------
--math = termX/2-3
if xpos >= 10 and xpos <= 15 and ypos == 4 then
toggle()
LockScreen()
end
if xpos >= 11 and xpos <= 14 and ypos == 5 then
toggle()
UnlockScreen()
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