CaelKohler

Filler de Pobre [MC 1.16.4] [V2] [WIP]

Jan 13th, 2021 (edited)
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = {...}
  2.  
  3. if #args ~= 3 then
  4.   print("Uso: "..shell.getRunningProgram().." <largura> <altura> <profundidade>")
  5.   return
  6. end
  7.  
  8. local needsFuel = turtle.getFuelLimit() ~= "unlimited"
  9.  
  10. local function refuel()
  11.   if needsFuel then
  12.     for i=16,1,-1 do
  13.         turtle.select(i)
  14.         turtle.refuel()
  15.     end
  16.   end
  17. end
  18.  
  19. local directions = {north=0, east=1, south=2, west=-1}
  20. local direction = directions.north
  21.  
  22. local function turn(newDirection)
  23.   if direction == newDirection then
  24.     return
  25.   end
  26.   local turnRelative = direction > 0 and turtle.turnLeft or turtle.turnRight
  27.   local turns = math.abs(newDirection - direction)
  28.   for i=1,turns do
  29.     turnRelative()
  30.   end
  31.   direction = newDirection
  32. end
  33.  
  34. local function forward(n)
  35.   n = n or 1
  36.   for i=1,n do
  37.     while turtle.detect() do
  38.       turtle.dig()
  39.     end
  40.     turtle.forward()
  41.   end
  42. end
  43.  
  44. local x = tonumber(args[1])
  45. local y = tonumber(args[2])-1
  46. local z = tonumber(args[3])
  47.  
  48.  
  49. term.clear()
  50. term.setCursorPos(1,1)
  51. print(string.format("Largura: %s \nAltura: %s \nProfundidade: %s",x,y+1,z))
  52.  
  53. local primary = x >= z and x or z
  54. local secondary x >= z and z or x
  55. direction = x >= z and directions.east or directions.north
  56.  
  57. for i=1,secondary do
  58.   for i=1,primary do
  59.     for i=1,y do
  60.       turn(direction)
  61.       while turtle.detect() do
  62.         turtle.dig()
  63.       end
  64.       if i ~= y do
  65.         while turtle.detectUp() do
  66.           turtle.digUp()
  67.         end
  68.       end
  69.       turtle.up()
  70.     end
  71.   end
  72. end
  73.  
  74. term.clear()
  75. term.setCursorPos(1,1)
RAW Paste Data