Barnet

BuildWalls

Dec 6th, 2017 (edited)
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function UP()
  2.   while not(turtle.up()) do
  3.     turtle.digUp()
  4.     turtle.attackUp()
  5.   end
  6. end
  7.  
  8. function DOWN()
  9.   while not(turtle.down()) do
  10.     turtle.digDown()
  11.     turtle.attackDown()
  12.   end
  13. end
  14.  
  15. function FORWARD()
  16.   while not(turtle.forward()) do
  17.     turtle.dig()
  18.     turtle.attack()
  19.   end
  20. end
  21.  
  22. function Name()
  23.   return turtle.getItemDetail().name
  24. end
  25.  
  26. function Select(material)
  27.   if pcall(Name) then
  28.     if Name() == material then
  29.       return true
  30.     end
  31.   end
  32.   for i=1,16,1 do
  33.     turtle.select(i)
  34.     if pcall(Name) then
  35.       if Name() == material then
  36.         return true
  37.       end
  38.     end
  39.   end
  40. write("Need more ")
  41. write(material)
  42. write("!")
  43. print("Press ENTER to continue...")
  44. read()
  45. return Select(material)
  46. end
  47.  
  48. function BuildColoumnUp(y,material)
  49.   for i=1,y,1 do
  50.     UP()
  51.     Select(material)
  52.     turtle.placeDown()
  53.   end
  54.   FORWARD()
  55.   DOWN()
  56. end
  57.  
  58. function BuildColoumnDown(y,material)
  59.   for i=1,y,1 do
  60.     DOWN()
  61.     Select(material)
  62.     turtle.placeUp()
  63.   end
  64.   FORWARD()
  65.   UP()
  66. end
  67.  
  68. function BuildRow(x,y,material)
  69.   if (x % 2 == 0) then
  70.     for i=1,x/2,1 do
  71.       BuildColoumnUp(y,material)
  72.       BuildColoumnDown(y,material)
  73.     end
  74.   else
  75.     for i=1,(x-1)/2,1 do
  76.       BuildColoumnUp(y,material)
  77.       BuildColoumnDown(y,material)
  78.     end
  79.     BuildColoumnUp(y,material)
  80.     for i=2,y,1 do
  81.       DOWN()
  82.     end
  83.   end
  84. end
  85.  
  86. function BuildWalls(x,y,z,material)
  87.   for i=0,1,1 do
  88.     BuildRow(x,y,material)
  89.     turtle.turnRight()
  90.     FORWARD()
  91.     BuildRow(z,y,material)
  92.     turtle.turnRight()
  93.     FORWARD()
  94.   end
  95. end
  96.  
  97. print("---------------------")
  98. write("Height: ")
  99. y = read()
  100. write("Length: ")
  101. x = read()
  102. write("Width: ")
  103. z = read()
  104. write("Material: ")
  105. material = read()
  106. print("Building....")
  107. BuildWalls(x,y,z,material)
  108. print("Done!")
RAW Paste Data