CelticCoder

findBlocks

Jan 10th, 2024 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. function findBlock(blockName)
  2.     for slot = 1, 16 do
  3.         local itemDetail = turtle.getItemDetail(slot)
  4.         if itemDetail and itemDetail.name == blockName then
  5.             return slot
  6.         end
  7.     end
  8.     return nil
  9. end
  10.  
  11. function findBlocks(blockName)
  12.     local foundSlots = {}
  13.     for slot = 1, 16 do
  14.         local itemDetail = turtle.getItemDetail(slot)
  15.         if itemDetail and itemDetail.name == blockName then
  16.             table.insert(foundSlots, slot)
  17.         end
  18.     end
  19.     return foundSlots -- Return a table containing slots with the block
  20. end
  21.  
Add Comment
Please, Sign In to add comment