Orginalet

spleefer

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