Advertisement
djPtica

CCdigBox

Jun 29th, 2025 (edited)
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. local tArgs = {...}
  2. local forward = 0
  3. local right = 0
  4. local down = 0
  5.  
  6. forward = tonumber(tArgs[1])
  7. right = tonumber(tArgs[2])
  8. down = tonumber(tArgs[3])
  9.  
  10. function moveForward(n)
  11.     for i=1, n do
  12.         while not turtle.forward() do
  13.             turtle.dig()
  14.             turtle.attack()
  15.         end
  16.     end
  17. end
  18.  
  19. function rotateBack()
  20.     turtle.turnLeft()
  21.     turtle.turnLeft()
  22. end
  23.  
  24. function checkFull()
  25.     if turtle.getItemCount(16)>0 then
  26.         getBack()
  27.     end
  28. end
  29.  
  30. function checkFuel()
  31.     while true do
  32.         fuel = turtle.getFuelLevel()
  33.         if fuel<(forward*right*depth*20) then
  34.             print("Not enough fuel")
  35.             print("Put fuel in slot 1")
  36.             --turtle.refuel(turtle.getItemCount(1))
  37.             turtle.refuelAll()
  38.         else
  39.             break
  40.         end
  41.         print("Fuel OK")
  42.         sleep(3)
  43.     end
  44. end
  45.  
  46. function getBack(f, r, d, dir)
  47.     if dir==0 then
  48.         rotateBack()
  49.     end
  50.     if d>0 then
  51.         for i=1, d do
  52.             turtle.up()
  53.         end
  54.     end
  55.     if r>0 then
  56.         turtle.turnRight()
  57.         moveForward(r)
  58.         turtle.turnLeft()
  59.     end
  60.     moveForward(f)
  61. end
  62.  
  63. function changeDirection()
  64.     if direction==0 then
  65.         direction = 1
  66.     else
  67.         direction = 0
  68.     end
  69. end
  70.  
  71. --MAIN
  72. local movedForward = 0
  73. local movedRight = 0
  74. local movedDown = 0
  75. local direction = 0
  76.  
  77. if down>0 then
  78.     --checkFuel()
  79.     moveForward(1)
  80.     for d=1, down do
  81.         for r=1, right do
  82.             for f=1, forward-1 do
  83.             print("Kopam naprijed")
  84.                 moveForward(1)
  85.                 if direction == 0 then
  86.                     movedForward = movedForward + 1
  87.                 else
  88.                     movedForward = movedForward - 1
  89.                 end
  90.             end
  91.             if movedRight<right-1 then
  92.                 print("Trebam desno")
  93.                 if direction==0 then
  94.                     print("Okrecem desno")
  95.                     turtle.turnRight()
  96.                     moveForward(1)
  97.                     turtle.turnRight()
  98.                     movedRight = movedRight + 1
  99.                     changeDirection()
  100.                 else
  101.                     print("Okrecem lijevo")
  102.                     turtle.turnLeft()
  103.                     moveForward(1)
  104.                     turtle.turnLeft()
  105.                     movedRight = movedRight + 1
  106.                     changeDirection()
  107.                 end
  108.             end
  109.         end
  110.         if movedDown<down-1 then
  111.             print("Idem dole")
  112.             turtle.digDown()
  113.             turtle.down()
  114.         end
  115.     end
  116.     getBack(movedForward, movedRight, movedDown, direction)
  117. else
  118.     print("Set all parameters: Forward, Right, Down")
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement