Advertisement
gravitowl

soulvialfarm

Dec 10th, 2024 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local function findItem(itemName)
  2.     for i=1,16 do
  3.         local itemDetail = turtle.getItemDetail(i);
  4.  
  5.         if itemDetail and itemDetail.name == itemName then
  6.             return i;
  7.         end
  8.     end
  9.  
  10.     return -1;
  11. end
  12.  
  13. local function digSand()
  14.     local hasBlock, blockData = turtle.inspect();
  15.  
  16.     if hasBlock and blockData.name == "minecraft:sand" then
  17.         turtle.dig();
  18.     end
  19. end
  20.  
  21. local function main()
  22.     while true do
  23.         digSand();
  24.         local sandSlot = findItem("minecraft:sand");
  25.    
  26.         if sandSlot ~= -1 then
  27.             turtle.select(sandSlot);
  28.             turtle.dropUp();
  29.         end
  30.    
  31.         local soulsandSlot = findItem("minecraft:soul_sand");
  32.    
  33.         if soulsandSlot ~= -1 and not turtle.detect() then
  34.             turtle.select(soulsandSlot);
  35.             turtle.place();
  36.         end
  37.     end
  38. end
  39.  
  40. main();
  41.  
  42. -- DESIGN GOALS
  43. -- 1. Place soul sand when in inventory.
  44. -- 2. Mine sand if found in front of turtle.
  45. -- 3. Drop sand upwards if found in inventory.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement