Advertisement
ItsNoah

packyourstuff

Apr 22nd, 2021 (edited)
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.84 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3. local depth = 0
  4. local xPos,zPos = 0,0
  5. local xDir,zDir = 0,1
  6.  
  7. local goTo
  8.  
  9. local count = 0
  10.  
  11. local function turnLeft()
  12.     turtle.turnLeft()
  13.     xDir, zDir = -zDir, xDir
  14. end
  15.  
  16. local function turnRight()
  17.     turtle.turnRight()
  18.     xDir, zDir = zDir, -xDir
  19. end
  20.  
  21. function goTo( x, y, z, xd, zd )
  22.     while depth > y do
  23.         if turtle.up() then
  24.             depth = depth - 1
  25.         else
  26.             turtle.digUp()
  27.         end
  28.     end
  29.  
  30.     if xPos > x then
  31.         while xDir ~= -1 do
  32.             turnLeft()
  33.         end
  34.         while xPos > x do
  35.             if turtle.forward() then
  36.                 xPos = xPos - 1
  37.             else
  38.                 turtle.dig()
  39.             end
  40.         end
  41.     elseif xPos < x then
  42.         while xDir ~= 1 do
  43.             turnLeft()
  44.         end
  45.         while xPos < x do
  46.             if turtle.forward() then
  47.                 xPos = xPos + 1
  48.             else
  49.                 turtle.dig()
  50.             end
  51.         end
  52.     end
  53.    
  54.     if zPos > z then
  55.         while zDir ~= -1 do
  56.             turnLeft()
  57.         end
  58.         while zPos > z do
  59.             if turtle.forward() then
  60.                 zPos = zPos - 1
  61.             else
  62.                 turtle.dig()
  63.             end
  64.         end
  65.     elseif zPos < z then
  66.         while zDir ~= 1 do
  67.             turnLeft()
  68.         end
  69.         while zPos < z do
  70.             if turtle.forward() then
  71.                 zPos = zPos + 1
  72.             else
  73.                 turtle.dig()
  74.             end
  75.         end
  76.     end
  77.  
  78.     while depth < y do
  79.         if turtle.down() then
  80.             depth = depth + 1
  81.         else
  82.             turtle.digDown()
  83.         end
  84.     end
  85.    
  86.     if zd ~= xd then
  87.         while zDir ~= zd or xDir ~= xd do
  88.             turnRight()
  89.         end
  90.     end
  91. end
  92.  
  93. -- start --
  94.  
  95. turtle.select(1)
  96. goTo(1, 1, 0, 0, -1)
  97.  
  98. local scanning = true
  99.  
  100. while scanning do
  101.     local success, data = turtle.inspect()
  102.     if success and data.name == "minecraft:hopper" then
  103.         count = count + 1
  104.         goTo(1, (1 + count), 0, 0, -1)
  105.     else
  106.         scanning = false
  107.     end
  108. end
  109.  
  110. goTo(0, 0, 0, 0, -1)
  111. turtle.dig()
  112. goTo(0, 0, -1, 0, -1)
  113. turnLeft() turtle.dig() turnRight()
  114. goTo(0, 0, -2, 1, 0)
  115.  
  116. for i=1, count do
  117.     goTo(0, i, -2, 1, 0)
  118.     turtle.dig() turtle.digDown()
  119. end
  120.  
  121. goTo(1, count, -2, -1, 0)
  122. goTo(1, count, -1, -1, 0)
  123. goTo(1, 0, -1, -1, 0)
  124.  
  125. goTo(0, 0, 0, 0, 1)
  126.  
  127. print("Packed!")
  128.  
  129. if #tArgs > 0 then
  130.     if tArgs[1] == "go" then
  131.         local n = 0
  132.         local arrived = false
  133.         while not arrived do
  134.             if turtle.forward() then
  135.                 n = n + 1
  136.                 if n == 16 then
  137.                     arrived = true
  138.                 end
  139.             else
  140.                 turtle.dig()
  141.             end
  142.         end
  143.         shell.run("setup exf")
  144.     end
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement