Barnet

Minecraft Turtle: BuildPlane

Apr 24th, 2016 (edited)
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. -----------Written by Barnet-----------
  2.  
  3. function CheckSlot(Material)
  4.   if turtle.getItemCount() ~= 0 then
  5.     if turtle.getItemDetail().name == Material then
  6.       return true
  7.     else
  8.       return false
  9.     end
  10.   else
  11.     return false
  12.   end
  13. end
  14.  
  15. function Refill(Material)
  16.   if CheckSlot(Material) == false then
  17.     x = 1
  18.     while x<17 do
  19.       turtle.select(x)
  20.       x=x+1
  21.       if CheckSlot(Material) == true then
  22.         x=17
  23.       elseif x == 17 then
  24.         turtle.select(1)
  25.         print("Missing Material")
  26.         error()
  27.       end
  28.     end
  29.   end
  30. end
  31.  
  32. function PlaceDown(Material)
  33.   Refill(Material)
  34.   if turtle.detectDown() == true and turtle.compareDown() == false then
  35.     turtle.digDown()
  36.   end
  37.   turtle.placeDown()
  38. end
  39.  
  40. function Forward()
  41.   while turtle.forward() == false do
  42.     if turtle.detect() == true then
  43.       turtle.dig()
  44.     else
  45.       turtle.attack()
  46.     end
  47.   end  
  48. end  
  49.  
  50. function BuildForward(a,Material)
  51.   y=1
  52.   while y<a do
  53.     PlaceDown(Material)
  54.     Forward()
  55.     y=y+1
  56.   end
  57. end
  58.  
  59. function BuildRight(Material)
  60.   PlaceDown(Material)
  61.   turtle.turnRight()
  62.   Forward()
  63.   turtle.turnRight()
  64. end
  65.  
  66. function BuildLeft(Material)
  67.   PlaceDown(Material)
  68.   turtle.turnLeft()
  69.   Forward()
  70.   turtle.turnLeft()
  71. end
  72.  
  73. function BuildPlane(a,b,Material)
  74.   c=0
  75.   while c<b/2 do
  76.     BuildForward(a,Material)
  77.     BuildRight(Material)
  78.     BuildForward(a,Material)
  79.     BuildLeft(Material)
  80.     c=c+1
  81.   end
  82. end
  83.  
  84. print()  
  85. print("Build a Plane")
  86. print("---------------------------------------")
  87. write("Length: ")
  88. a = tonumber(read())
  89. write("Width: ")
  90. b = tonumber(read())
  91. write("Material: ")
  92. Material = read()
  93. print("Building Plane...")
  94. BuildPlane(a,b,Material)
  95. print("Done!")
Add Comment
Please, Sign In to add comment