legg0028

floor

Mar 28th, 2021 (edited)
1,087
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. local tArgs = {...}
  2.  
  3. if (not tArgs[1]) or (not tArgs[2]) then
  4.   print("Set parameters: <length> <width>")
  5.   return
  6. end
  7.  
  8. local checkArg = tArgs[1]
  9. local origLong = tonumber(checkArg)
  10. local long = tonumber(checkArg)-1
  11.  
  12. checkArg = tArgs[2]
  13. local origWide = tonumber(checkArg)
  14. local wide = tonumber(checkArg)-1
  15.  
  16. if tArgs[3] == "-c" then
  17.   ceiling = TRUE
  18. end
  19.  
  20. function goForward()
  21.   while (not turtle.forward()) do
  22.       turtle.dig()
  23.       turtle.attack()
  24.       sleep(0.1)
  25.   end
  26. end
  27.  
  28. function checkItems()
  29.   if turtle.getItemCount() < 1 then
  30.     repeat
  31.         selected = turtle.getSelectedSlot()
  32.         turtle.select(selected+1)
  33.     until (selected == 15) or (turtle.getItemCount() > 0)
  34.     if (turtle.getSelectedSlot() == 16)  and (turtle.getItemDetail(16)["name"] == "enderstorage:ender_chest") then
  35.         turtle.place()
  36.         for k = 1,15 do
  37.             turtle.select(k)
  38.             turtle.suck()
  39.         end
  40.         turtle.select(16)
  41.         if turtle.getItemCount(16) > 0 then
  42.             turtle.drop()
  43.         end
  44.         turtle.dig()
  45.         turtle.select(1)
  46.     end
  47.   end
  48. end
  49.  
  50. function place()
  51.   checkItems()
  52.   if tArgs[3] == "-c" then
  53.     turtle.placeUp()
  54.   else
  55.     turtle.placeDown()
  56.   end
  57.   goForward()
  58. end
  59.  
  60. function row()
  61.   for x = 1,(long) do
  62.     place()
  63.   end
  64. end
  65.  
  66. term.clear()
  67. term.setCursorPos(1,1)
  68. if tArgs[3] == "-c" then
  69.     print("Your ceiling will be "..origLong.."x"..origWide)
  70.     print("Place turtle on the top right corner BELOW the area to be ceilinged.")
  71. else
  72.     print("Your floor will be "..origLong.."x"..origWide)
  73.     print("Place turtle on the top right corner ABOVE the area to be floored.")
  74. end
  75. io.read()
  76.  
  77. local currentRow = 1
  78. repeat
  79.     row()
  80.     if (currentRow % 2 == 0) then
  81.         turtle.turnRight()
  82.         place()
  83.         turtle.turnRight()
  84.         currentRow = currentRow + 1
  85.     else
  86.         turtle.turnLeft()
  87.         place()
  88.         turtle.turnLeft()
  89.         currentRow = currentRow + 1
  90.     end
  91. until currentRow > wide
  92. row()
  93. if (origWide % 2 == 0) then
  94.     turtle.turnLeft()
  95.     for x = 1,wide do
  96.         place()
  97.     end
  98.     turtle.turnLeft()
  99. else
  100.     turtle.turnLeft()
  101.     turtle.turnLeft()
  102.     for x = 1,long do
  103.         place()
  104.     end
  105.     turtle.turnLeft()
  106.     for x = 1,wide do
  107.         place()
  108.     end
  109.     turtle.turnLeft()
  110. end
Add Comment
Please, Sign In to add comment