Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Sender
- --Id of the reciver
- id = 4
- --True if you want that a password is necessary to change the output
- pwnecessary = true
- --Password (4 symbols)
- code = 1234
- --Wireless modem (currently at the top)
- rednet.open("top")
- --Monitor (currently at the back)
- monitor = peripheral.wrap("back")
- function clrmonitor()
- for i=1,7 do
- for o=1,5 do
- monitor.setCursorPos(i,o)
- monitor.setTextColor(1)
- monitor.setBackgroundColor(32768)
- monitor.write("O")
- end
- end
- monitor.clear()
- monitor.setCursorPos(1,1)
- end
- function question()
- choose = false
- rednet.send(id,"question")
- event, id, message, distance = os.pullEvent("rednet_message")
- while choose == false do
- clrmonitor()
- monitor.write("Status:")
- for i=2,6 do
- for o=2,4 do
- if message == "on" then
- monitor.setCursorPos(i,o)
- monitor.setBackgroundColor(8192)
- monitor.setTextColor(8192)
- monitor.write("O")
- else
- monitor.setCursorPos(i,o)
- monitor.setBackgroundColor(16384)
- monitor.setTextColor(16384)
- monitor.write("O")
- end
- end
- end
- --monitor.setBackgroundColor(32768)
- monitor.setTextColor(1)
- monitor.setCursorPos(3,3)
- monitor.write(message)
- event, side, x, y = os.pullEvent("monitor_touch")
- if y >= 2 or y <= 4 then
- if x >= 2 and x <= 6 then
- choose = true
- end
- end
- end
- end
- function setnumber()
- clrmonitor()
- monitor.setCursorPos(3,2)
- monitor.write("1")
- monitor.setCursorPos(4,2)
- monitor.write("2")
- monitor.setCursorPos(5,2)
- monitor.write("3")
- monitor.setCursorPos(3,3)
- monitor.write("4")
- monitor.setCursorPos(4,3)
- monitor.write("5")
- monitor.setCursorPos(5,3)
- monitor.write("6")
- monitor.setCursorPos(3,4)
- monitor.write("7")
- monitor.setCursorPos(4,4)
- monitor.write("8")
- monitor.setCursorPos(5,4)
- monitor.write("9")
- monitor.setCursorPos(4,5)
- monitor.write("0")
- monitor.setCursorPos(1,1)
- end
- function getinput()
- repeat
- if x == 3 and y == 2 then
- input = 1
- elseif x == 4 and y == 2 then
- input = 2
- elseif x == 5 and y == 2 then
- input = 3
- elseif x == 3 and y == 3 then
- input = 4
- elseif x == 4 and y == 3 then
- input = 5
- elseif x == 5 and y == 3 then
- input = 6
- elseif x == 3 and y == 4 then
- input = 7
- elseif x == 4 and y == 4 then
- input = 8
- elseif x == 5 and y == 4 then
- input = 9
- elseif x == 4 and y == 5 then
- input = 0
- else
- input = 10
- event, side, x, y = os.pullEvent("monitor_touch")
- end
- until input ~= 10
- end
- while true do
- clrmonitor()
- question()
- if pwnecessary == true then
- setnumber()
- output = 0
- for i=1,4 do
- event, side, x, y = os.pullEvent("monitor_touch")
- if event == "monitor_touch" then
- getinput()
- monitor.setTextColor(2048)
- monitor.setCursorPos(i+2,1)
- monitor.write(input)
- monitor.setCursorPos(i+1+2,1)
- monitor.write(" ")
- monitor.setCursorPos(i+2+2,1)
- monitor.write(" ")
- monitor.setTextColor(1)
- if i == 1 then
- output = output + input * 1000
- elseif i == 2 then
- output = output + input * 100
- elseif i == 3 then
- output = output + input * 10
- elseif i == 4 then
- output = output + input
- end
- end
- end
- if output == code then
- if message == "off" then
- rednet.send(id,"on")
- else
- rednet.send(id,"off")
- end
- end
- print(output)
- else
- if message == "off" then
- rednet.send(id,"on")
- else
- rednet.send(id,"off")
- end
- end
- sleep(0.5)
- clrmonitor()
- end
Advertisement
Add Comment
Please, Sign In to add comment