TNT_Nolan

Turtle Controller

Apr 22nd, 2016
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. while true do
  2. notclicked = true
  3. side = "top"
  4. rednet.open(side)
  5. term.setBackgroundColor(colors.white)
  6. term.setCursorPos(1,1)
  7. term.clear()
  8. term.setTextColor(colors.blue)
  9. print("Welcome to turtle control!")
  10. term.setTextColor(colors.lime)
  11. paintutils.drawFilledBox(2,2,16,5,colors.yellow)
  12. paintutils.drawFilledBox(19,2,32,5,colors.yellow)
  13. paintutils.drawFilledBox(2,7,16,10,colors.yellow)
  14. paintutils.drawFilledBox(19,7,32,10,colors.yellow)
  15. paintutils.drawFilledBox(2,12,16,15,colors.yellow)
  16. paintutils.drawFilledBox(19,12,32,15,colors.yellow)
  17. term.setCursorPos(6,3)
  18. print("Forward")
  19. term.setCursorPos(21,3)
  20. print("Backwards")
  21. term.setCursorPos(6,8)
  22. print("Left")
  23. term.setCursorPos(21,8)
  24. print("Right")
  25. term.setCursorPos(6,13)
  26. print("Turn Left")
  27. term.setCursorPos(21,13)
  28. print("Turn Right")
  29. while notclicked do
  30. event,button,x,y = os.pullEvent("mouse_click")
  31. if x == 2 and y == 2 or x == 16 and y == 5 or x > 2 and x < 16 and y > 2 and y < 5 then
  32. rednet.open(side)
  33. rednet.broadcast("forward")
  34. rednet.close(side)
  35. elseif x == 19 and y == 2 or x == 32 and y == 5 or x > 19 and x < 32 and y > 2 and y < 5 then
  36. rednet.open(side)
  37. rednet.broadcast("backwards")
  38. rednet.close(side)
  39. elseif x == 2 and y == 7 or x == 16 and y == 10 or x > 2 and x < 16 and y > 7 and y < 10 then
  40. rednet.open(side)
  41. rednet.broadcast("left")
  42. rednet.close(side)
  43. elseif x == 19 and y == 7 or x == 32 and y == 10 or x > 19 and x < 32 and y > 7 and y < 10 then
  44. rednet.open(side)
  45. rednet.broadcast("right")
  46. rednet.close(side)
  47. elseif x == 2 and y == 12 or x == 16 and y == 17 or x > 2 and x < 16 and y > 12 and y < 17 then
  48. rednet.open(side)
  49. rednet.broadcast("turnleft")
  50. rednet.close()
  51. elseif x == 19 and y == 12 or x == 32 and y == 17 or x > 19 and x < 32 and y > 12 and y < 17 then
  52. rednet.open(side)
  53. rednet.broadcast("turnright")
  54. rednet.close()
  55. end
  56. end
  57. end
Add Comment
Please, Sign In to add comment