Advertisement
camarajohnny

temp

Mar 17th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. robot = require("robot")
  2. component = require("component")
  3. os = require("os")
  4.  
  5. nav = component.navigation
  6.  
  7. waitTime = 30 -- how long to wait after unloading
  8. function unload()
  9.  
  10. for i = 1, 16 do
  11. robot.select(i)
  12. robot.dropUp()
  13. end
  14. robot.select(1)
  15. end
  16.  
  17. function forwardFarm()
  18. local isMoved = false
  19. robot.swingDown()
  20. robot.placeDown()
  21. while isMoved ~= true do
  22. isMoved = robot.forward()
  23. end
  24. end
  25. function turnRight(dir)
  26.  
  27. while dir ~= nav.getFacing() do
  28. robot.turnRight()
  29. end
  30. end
  31. function turnLeft(dir)
  32. while dir ~= nav.getFacing() do
  33. robot.turnLeft()
  34. end
  35. end
  36.  
  37. function doTurn()
  38. local x, y, z = nav.getPosition()
  39. local dir = nav.getFacing()
  40. local temp = 0
  41. local face = dir
  42. if z == 44.5 then
  43. temp = math.floor(x)
  44. temp = temp % 2
  45. if temp == 1 then
  46. face = 4
  47. else
  48. face = 2
  49. end
  50. turnRight(face)
  51. elseif z == 29.5 then
  52. temp = math.floor(x)
  53. temp = temp % 2
  54. if x ~= -65.5 or x ~= -49.5 then
  55. if temp == 0 then
  56. face = 4
  57. else
  58. face = 3
  59. end
  60. end
  61. turnLeft(face)
  62. elseif z == 28.5 then
  63. if x == -65.5 then
  64. face = 5
  65. elseif x == -49.5 then
  66. face = 3
  67. end
  68. turnRight(face)
  69. end
  70.  
  71. end
  72.  
  73. while true do
  74. robot.forward()
  75. doTurn()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement