Advertisement
Jameelo

mineLib

Apr 26th, 2025 (edited)
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | Gaming | 0 0
  1. --[[
  2.     Library focussed on moving about & mining
  3. ]]
  4.  
  5. function digForward(length) -- Variable length dig forward command.
  6.     if length == nil then
  7.         length = 1 -- default
  8.     end
  9.     for _ = 1,length,1 do        
  10.         -- keep digging until nothing remains in front of you
  11.         repeat
  12.             turtle.dig()
  13.             os.sleep(0.1)
  14.         until not turtle.detect()
  15.  
  16.         turtle.forward()
  17.         if everySlotTaken() == true then
  18.             print("Storage full! Dumping items...")
  19.             dumpItems()
  20.         end
  21.     end
  22. end
  23.  
  24. function placeMoveForward(length, block) -- places the currently selected block & moves forward.
  25.     --[[
  26.         True - returned as length was reached
  27.         False - returned due to lack of items
  28.     ]]
  29.  
  30.     for _ = 1,length,1 do        
  31.         if turtle.getItemCount() == 0 then -- if no blocks are left, reload.
  32.             newSlot = storageLib.findItemBF(block)
  33.             if newSlot > 0 then -- if there is another stack in the inventory
  34.                 turtle.select(newSlot) -- select another instance of the block
  35.             else
  36.                 return false -- ran outta blocks
  37.             end
  38.         end
  39.  
  40.         if turtle.detect() then -- if there is an obstacle, even though there shouldn't be.
  41.             turtle.dig() -- This opens up the possibility of filling the inventory I guess? Not an issue atm.
  42.         end
  43.  
  44.         if not turtle.detectDown() then
  45.             turtle.placeDown()
  46.         end
  47.         turtle.forward()
  48.     end
  49.  
  50.     return true
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement