Advertisement
Guest User

screen

a guest
Jul 31st, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. rednet.open("top")
  2. m = peripheral.wrap("back")
  3. m.clear()
  4. m.setBackgroundColor(colors.black)
  5. m.clear()
  6. x, y = m.getSize()
  7.  
  8. function getClick()
  9.   while true do
  10.     event, side, x, y =os.pullEvent("monitor_touch")
  11.     return x, y
  12.   end
  13. end
  14.  
  15. function creatButton(xmin, ymin, xmax, ymax, txt)
  16.   for i = xmin, xmax do
  17.     for k = ymin, ymax do
  18.       m.setCursorPos(i, k)
  19.       m.write(" ")
  20.     end
  21.   end
  22.   m.setCursorPos(xmin+3,ymin+1)
  23.   m.write(txt)
  24. end
  25.  
  26. m.setBackgroundColor(colors.green)  
  27. creatButton(2, 2, 19, 5, "turbine 1 on")
  28. creatButton(53, 2, 70, 5, "turbine 2 on")
  29.  
  30. function receive(comp, xmin, ymin, xmax, ymax, txt1, txt2)
  31.   id, msg, dist = rednet.receive()
  32.   if id == comp then
  33.     if msg == "on" then
  34.       m.setBackgroundColor(colors.green)
  35.       creatButton(xmin, ymin ,xmax, ymax, txt1)
  36.     else
  37.       m.setBackgroundColor(colors.red)
  38.       creatButton(xmin, ymin , xmax, ymax, txt2)
  39.     end
  40.   end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement