AdditionalPylons

build_floor.lua

Jun 5th, 2026 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local l,w = ...
  2. local b=true
  3. local function rotate()
  4.     if b then
  5.         turtle.turnLeft()
  6.         turtle.forward()
  7.         turtle.turnLeft()
  8.     else
  9.         turtle.turnRight()
  10.         turtle.forward()
  11.         turtle.turnRight()
  12.     end
  13.     b = not b
  14. end
  15. local function slot_plus() turtle.select(turtle.getSelectedSlot()%16+1) end
  16. local function floor_block()
  17.     if not turtle.compareDown() then
  18.         turtle.digDown()
  19.         if not turtle.placeDown() then
  20.             slot_plus()
  21.             turtle.placeDown()
  22.         end
  23.         while turtle.getItemCount()==0 do slot_plus() end
  24.     end
  25. end
  26. local function floor_line(n)
  27.     for j=1,n do
  28.         floor_block()
  29.         turtle.forward()
  30.     end
  31. end
  32. local function build_floor(l,w)
  33.     b=true
  34.     for i=1,w-1 do
  35.         floor_line(l-1)
  36.         floor_block()
  37.         rotate()
  38.     end
  39.     floor_line(l-1)
  40.     floor_block()
  41. end
  42. if not l then
  43.     error("Must have two arguments: length and width.")
  44. end
  45. if tonumber(l) and tonumber(w) then
  46.     build_floor(l,w)
  47. end
  48. return {build=build_floor}
  49.  
Advertisement
Add Comment
Please, Sign In to add comment