Advertisement
woflmao

buildFloor

Jun 16th, 2024 (edited)
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. local tArgs = {...}
  2.  
  3. if #tArgs == 0 then
  4.     print("Please input a length")
  5.     length = 0
  6.     rows = 0
  7. elseif (tonumber(tArgs[1]% == 0) then
  8.     print("Please enter an even number (bot has to return)")
  9.     length = 0
  10.     rows = 0
  11. elseif #tArgs == 1 then
  12.     length = (tonumber(tArgs[1]) - 2)
  13.     rows = 0
  14. else
  15.     length = (tonumber(tArgs[1]) - 2)
  16.     rows = tonumber(tArgs[2])
  17. end
  18.  
  19. turtle.select(1)
  20. itemCount = turtle.getItemCount(1)
  21.  
  22. function PlaceAndCheck()
  23.     if (itemCount == 0) then
  24.         Restock()
  25.     end
  26.     turtle.place()
  27.     itemCount = itemCount - 1
  28. end
  29.  
  30. function Restock()
  31.     if (turtle.getItemCount(turtle.getSelectedSlot()) == 0) then
  32.         if (turtle.getSelectedSlot() == 16) then
  33.             return
  34.         else
  35.             turtle.select(turtle.getSelectedSlot() + 1)
  36.             itemCount = turtle.getItemCount(turtle.getSelectedSlot())
  37.         end
  38.     end
  39. end
  40.  
  41. function rowOne()
  42.     Restock()
  43.     for i=1, length, 1 do
  44.         PlaceAndCheck()
  45.         turtle.back()
  46.     end
  47.     PlaceAndCheck()
  48.     turtle.turnRight()
  49.     turtle.back()
  50.     PlaceAndCheck()
  51.     turtle.turnRight()
  52.     turtle.back()
  53. end
  54.  
  55. function rowTwo()
  56.     Restock()
  57.     for i=1, length, 1 do
  58.         PlaceAndCheck()
  59.         turtle.back()
  60.     end
  61.     PlaceAndCheck()
  62.     turtle.turnLeft()
  63.     turtle.back()
  64.     PlaceAndCheck()
  65.     turtle.turnLeft()
  66.     turtle.back()
  67. end
  68.    
  69.  
  70. if rows > 0 then
  71.     for i=1, rows, 1 do
  72.         rowOne()
  73.         rowTwo()
  74.         print(string.format("Row %s", i))
  75.     end
  76. else
  77.     rowOne()
  78. end
Tags: minecraft
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement