Advertisement
Guest User

client

a guest
Jun 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. rednet.open("right")
  2. mon = peripheral.wrap("back")
  3. local rubber = false
  4. local light = false
  5. while(true)do
  6.  
  7. mon.setCursorPos(2,2)
  8. if (rubber) then
  9. mon.setBackgroundColor(colors.green)
  10. else
  11. mon.setBackgroundColor(colors.red)
  12. end
  13. mon.write("Rubber Farm")
  14.  
  15.  
  16. event, side, x, y = os.pullEvent("monitor_touch")
  17. print(x)
  18. print(y)
  19.  
  20. if(x>2 and x<14 and y>1 and y<4)then
  21. rednet.send(13,"rubber")
  22. end
  23.  
  24. rednet.send(13,"update")
  25. local rec = true
  26.  
  27. rubber =false
  28. light = false
  29.  
  30. while (rec) do
  31.  
  32. local senderId, message, protocol = rednet.receive()
  33.  
  34. if(message=="rubber")then
  35.   rubber = true
  36.   end
  37. if(message=="light")then
  38.   light = true
  39.   end
  40. if(message=="end")then
  41.   rec = false
  42.   end
  43.  
  44. end
  45.  
  46. if (rubber) then
  47. print("Rubber ist an")
  48. else
  49. print("Rubber ist aus")
  50. end
  51. if(light)then
  52. print("light ist an")
  53. else
  54. print("light ist aus")
  55. end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement