Advertisement
Captn_Mal1972

farm

Jan 20th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. --- farming first just move
  2.  
  3. local tArgs = { ... }
  4. if #tArgs ~= 2 then
  5. print( "Usage: farm <length> <width>" )
  6. return
  7. end
  8.  
  9. local length = tonumber( tArgs[1] )
  10. local width = tonumber( tArgs[2] )
  11. local leftRight = 0
  12. print ( "Farming"..length.."by "..width.."." )
  13.  
  14. --- move in a zig zag fashion around the farm using nested loops
  15.  
  16. for w=1, width do
  17. for l=1, length do
  18. turtle.digDown()
  19. turtle.select(16)
  20. turtle.placeDown()
  21. turtle.select(15)
  22. turtle.placeDown()
  23. turtle.forward()
  24. end
  25.  
  26. if leftRight == 0 then
  27. turtle.turnRight()
  28. else
  29. turtle.turnLeft()
  30. end
  31.  
  32. turtle.forward()
  33.  
  34. if(leftRight) == 0 then
  35. turtle.turnRight()
  36. else
  37. turtle.turnLeft()
  38. end
  39.  
  40. if leftRight == 0 then
  41. leftRight = 1
  42. else
  43. leftRight = 0
  44. end
  45. end
  46.  
  47. --- Get back to where you once belonged.
  48. --- Need to code else for even numbered width later
  49.  
  50. if width%2 ~= 0 then
  51. for n=1, length do
  52. turtle.forward()
  53. end
  54.  
  55. turtle.turnRight()
  56.  
  57. for n=1, width do
  58. turtle.forward()
  59. end
  60. turtle.turnRight()
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement