Advertisement
LDDestroier

Turtle House Builder

Oct 15th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. function fuelUp( amount )
  2.     for a = 1, 16, 1 do
  3.          data = turtle.getItemDetail(a)
  4.          if data.name == "Coal" then
  5.              turtle.select(a)
  6.              turtle.refuel( amount )
  7.          end
  8.     end
  9. end
  10. function fuelUpIfNeeded()
  11.     if turtle.getFuelLevel() <= 30 then
  12.         fuelUp(1)
  13.     end
  14. end
  15. fuelUp()
  16. if turtle.getFuelLevel() == 0 then
  17.     error("no fuel")
  18. end
  19. print("How far forward? (z of house)")
  20. zlength = read()
  21. print("How far right? (x of house)")
  22. xlength = read()
  23. print("How many floors?")
  24. floorsno = read()
  25. print("How high is the ceiling of each floor?")
  26. floorsheight = read()
  27. ylength = floorsno * (floorsheight + 1)
  28. print("Working...")
  29. if turtle.detectDown() == true then
  30.     turtle.up()
  31. end
  32. turtle.turnRight()
  33. turtle.turnRight()
  34. for y = 0, ylength, 1 do
  35.     if (y % floorsheight) == 0 then
  36.         for z = 1, zlength, 1 do
  37.         turtle.back()
  38.             for x = 1, xlength, 1 do
  39.                 if x ~= xlength then
  40.                     turtle.forward()
  41.                 end
  42.                 fuelUpIfNeeded()
  43.                 turtle.placeDown()
  44.             end
  45.             if z ~= zlength then
  46.                 if (z % 2) == 0 then
  47.                     turtle.turnRight()
  48.                     turtle.forward()
  49.                     turtle.turnRight()
  50.                 else
  51.                     turtle.turnLeft()
  52.                     turtle.forward()
  53.                     turtle.turnLeft()
  54.                 end
  55.             end
  56.         end
  57.         turtle.placeDown()
  58.     else
  59.         for a = 1, 2, 1 do
  60.             for z = 0, zlength, 1 do
  61.                 fuelUpIfNeeded()
  62.                 turtle.placeDown()
  63.                 turtle.forward()
  64.             end
  65.             turtle.turnLeft()
  66.             for x = 0, xlength, 1 do
  67.                 fuelUpIfNeeded()
  68.                 turtle.placeDown()
  69.                 turtle.forward()
  70.             end
  71.             turtle.turnLeft()
  72.         end
  73.     end
  74.     turtle.up()
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement