Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- m = peripheral.wrap("back")
- m.clear()
- m.setBackgroundColor(colors.black)
- m.clear()
- x, y = m.getSize()
- function getClick()
- while true do
- event, side, x, y =os.pullEvent("monitor_touch")
- return x, y
- end
- end
- function creatButton(xmin, ymin, xmax, ymax, txt)
- for i = xmin, xmax do
- for k = ymin, ymax do
- m.setCursorPos(i, k)
- m.write(" ")
- end
- end
- m.setCursorPos(xmin+3,ymin+1)
- m.write(txt)
- end
- m.setBackgroundColor(colors.green)
- creatButton(2, 2, 19, 5, "turbine 1 on")
- creatButton(53, 2, 70, 5, "turbine 2 on")
- function receive(comp, xmin, ymin, xmax, ymax, txt1, txt2)
- id, msg, dist = rednet.receive()
- if id == comp then
- if msg == "on" then
- m.setBackgroundColor(colors.green)
- creatButton(xmin, ymin ,xmax, ymax, txt1)
- else
- m.setBackgroundColor(colors.red)
- creatButton(xmin, ymin , xmax, ymax, txt2)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement