Orginalet

builder

Jan 30th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. --Variables
  2. length = 6 --The length of the inner area of the arena, only even numbers.
  3. side = "right" --Leave this alone.
  4. rows = 3 --Use half the rows, can only handle whole numbers.
  5.  
  6. --Functions
  7. function start() -- Controlling the movement and places blocks.
  8.    for i = 1,rows do
  9.      place()
  10.      move()
  11.      navigateRight()
  12.      place()
  13.      move()
  14.      navigateLeft()
  15.    end
  16. end
  17.  
  18. function home() -- Sends the turtle home, must be used after start() is done.
  19.      turtle.turnLeft()
  20.      turtle.forward()
  21.      turtle.forward()
  22.      turtle.forward()
  23.      turtle.forward()
  24.      turtle.forward()
  25.      turtle.forward()
  26.      turtle.turnRight()
  27.      turtle.back()
  28. end
  29.  
  30. function navigateRight() -- Handles the turtles navigation to the right.
  31.     turtle.turnRight()
  32.     turtle.forward()
  33.     turtle.turnRight()
  34.     place()
  35. end
  36.  
  37. function navigateLeft() -- Handles the turtles navigation to the left.
  38.     turtle.turnLeft()
  39.     turtle.forward()
  40.     turtle.turnLeft()
  41.     place()
  42. end
  43.  
  44. function move() -- Places a block and then moves the turtle forward.
  45.    for i = 1,length do
  46.     place()
  47.     turtle.forward()
  48.    end
  49. end
  50.  
  51. function place() -- Handles the placement of blocks.
  52.     if turtle.detectUp() == false then
  53.        turtle.placeUp()
  54.     else
  55.        turtle.forward()
  56.     end
  57. end
  58.  
  59. -- Code to be executed
  60. start()
  61. home()
Advertisement
Add Comment
Please, Sign In to add comment