Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("monitor_0")
- rednet.open("left")
- local slate1 = 0
- local slate2 = 0
- local slate3 = 0
- local slate4 = 0
- local slate5 = 0
- function allOff()
- for i = 43, 47 do
- rednet.send(i, "0")
- end
- sleep(0.5)
- end
- function check()
- event, side, xi, yi = os.pullEvent("monitor_touch")
- for y = 2,4 do
- for x = 4,6 do
- if xi == x and yi == y then
- if slate1 == 1 then
- slate1 = 0
- allOff()
- rednet.send(43, "0")
- else
- slate1 = 1
- slate2 = 0
- slate3 = 0
- slate4 = 0
- slate5 = 0
- allOff()
- rednet.send(43, "1")
- end
- end
- end
- for x = 9,11 do
- if xi == x and yi == y then
- if slate2 == 1 then
- slate2 = 0
- allOff()
- rednet.send(44, "0")
- else
- slate1 = 0
- slate2 = 1
- slate3 = 0
- slate4 = 0
- slate5 = 0
- allOff()
- rednet.send(44, "1")
- end
- end
- end
- for x = 14,16 do
- if xi == x and yi == y then
- if slate3 == 1 then
- slate3 = 0
- allOff()
- rednet.send(45, "0")
- else
- slate1 = 0
- slate2 = 0
- slate3 = 1
- slate4 = 0
- slate5 = 0
- allOff()
- rednet.send(45, "1")
- end
- end
- end
- for x = 19, 21 do
- if xi == x and yi == y then
- if slate4 == 1 then
- slate4 = 0
- allOff()
- rednet.send(46, "0")
- else
- slate1 = 0
- slate2 = 0
- slate3 = 0
- slate4 = 1
- slate5 = 0
- allOff()
- rednet.send(46, "1")
- end
- end
- end
- for x = 24,26 do
- if xi == x and yi == y then
- if slate5 == 1 then
- slate5 = 0
- allOff()
- rednet.send(47, "0")
- else
- slate1 = 0
- slate2 = 0
- slate3 = 0
- slate4 = 0
- slate5 = 1
- allOff()
- rednet.send(47, "1")
- end
- end
- end
- end
- end
- function print()
- m.setBackgroundColor(32768)
- m.clear()
- m.setCursorPos(9,1)
- m.write("Slate-Control")
- for y = 2,4 do
- for x = 4,6 do
- m.setCursorPos(x,y)
- if slate1 == 0 then
- m.setBackgroundColor(16384)
- else
- m.setBackgroundColor(8192)
- end
- if x == 5 and y == 3 then
- m.write("1")
- else
- m.write(" ")
- end
- end
- for x = 9,11 do
- m.setCursorPos(x,y)
- if slate2 == 0 then
- m.setBackgroundColor(16384)
- else
- m.setBackgroundColor(8192)
- end
- if x == 10 and y == 3 then
- m.write("2")
- else
- m.write(" ")
- end
- end
- for x = 14,16 do
- m.setCursorPos(x,y)
- if slate3 == 0 then
- m.setBackgroundColor(16384)
- else
- m.setBackgroundColor(8192)
- end
- if x == 15 and y == 3 then
- m.write("3")
- else
- m.write(" ")
- end
- end
- for x = 19,21 do
- m.setCursorPos(x,y)
- if slate4 == 0 then
- m.setBackgroundColor(16384)
- else
- m.setBackgroundColor(8192)
- end
- if x == 20 and y == 3 then
- m.write("4")
- else
- m.write(" ")
- end
- end
- for x = 24,26 do
- m.setCursorPos(x,y)
- if slate5 == 0 then
- m.setBackgroundColor(16384)
- else
- m.setBackgroundColor(8192)
- end
- if x == 25 and y == 3 then
- m.write("5")
- else
- m.write(" ")
- end
- end
- end
- end
- sleep(1)
- allOff()
- print()
- while true do
- check()
- print()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement