Advertisement
KTRD

Filler

Feb 20th, 2025 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- Mock turtle API
  2. --[[
  3. local turtle = {
  4.     forward = function() end,
  5.     turnRight = function() end,
  6.     turnLeft = function() end,
  7.     placeDown = function() end,
  8.     getSelectedSlot = function()
  9.         return 0
  10.     end,
  11.     getItemCount = function(_)
  12.         return 0
  13.     end,
  14. }
  15. local math = {
  16.     fmod = function(_, _)
  17.         return 0
  18.     end,
  19. }
  20. local os = {
  21.     sleep = function(_) end,
  22. }
  23. --]]
  24.  
  25. local function placeDown()
  26.     while not turtle.placeDown() do
  27.         for i = 1, 16 do
  28.             if turtle.getItemCount(i) > 0 then
  29.                 turtle.select(i)
  30.                 break
  31.             end
  32.             if i == 16 then
  33.         os.sleep(10)
  34.       end
  35.         end
  36.     end
  37. end
  38.  
  39. local x, y = ...
  40. print("Filling a rectangle with sides " .. x .. " and " .. y)
  41. for i = 1, y do
  42.     turtle.forward()
  43.     if math.fmod(i, 2) == 1 then
  44.         turtle.turnRight()
  45.     else
  46.         turtle.turnLeft()
  47.     end
  48.  
  49.     for _ = 1, x - 1 do
  50.         placeDown()
  51.         turtle.forward()
  52.     end
  53.     placeDown()
  54.  
  55.     if math.fmod(i, 2) == 1 then
  56.         turtle.turnLeft()
  57.     else
  58.         turtle.turnRight()
  59.     end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement