Advertisement
carlosjuero

Minecraft Turtle Auto build column v1.0

Jul 14th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. tArgs = {...}
  2.  
  3. local currentLevel = 0
  4. local build = false
  5. local currentSlot = 1
  6. local length = 1
  7. local width = 1
  8.  
  9. function isEmpty(slot)
  10.   if turtle.getCount(slot) > 0 then
  11.     return false
  12.   else
  13.     return true
  14.   end
  15. end
  16.  
  17. function nextSlot()
  18.   currentSlot = currentSlot + 1
  19.   turtle.select(currentSlot)
  20. end
  21.  
  22. function buildColumn()
  23.     while turtle.detectDown() == false do
  24.         turtle.down()
  25.         currentLevel = currentLevel + 1
  26.       end
  27.  
  28.       if turtle.detectDown() == true then
  29.         for i = 1, currentLevel do
  30.           if isEmpty(currentSlot) == false
  31.             turtle.up()
  32.             turtle.placeDown()
  33.           else
  34.             nextSlot()
  35.             i = i - 1
  36.           end
  37.         end
  38.       end
  39. end
  40.  
  41. if tArgs[1] == nil then
  42.   print("Building a 1 x 1 column")
  43.   build = true
  44. else
  45.   if tArgs[2] == nil then
  46.     print("Invalid Usage.")
  47.     print("Usage:")
  48.     print("column")
  49.     print("column length width")
  50.     build = false
  51.   else
  52.     print("Building a "..tArgs[1].."x"..tArgs[2].." column")
  53.     build = true
  54.   end
  55. end
  56.  
  57. if build == true then
  58.   buildColumn()
  59.   currentLevel = 0
  60.   if length > 1 then
  61.     for i = 1, length do
  62.       if width > 1 then
  63.         turtle.turnLeft()
  64.         for i = 1, width do
  65.           turtle.forward()
  66.           buildColumn()
  67.           currentLevel = 0
  68.           for i = 1, width do
  69.             turtle.back()
  70.           end
  71.         end
  72.         turtle.turnRight()
  73.       end
  74.       turtle.forward()
  75.       buildColumn()
  76.       currentLevel = 0
  77.     end
  78.     for i = 1, length do
  79.       turtle.back()
  80.     end
  81.   end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement