I tried to write a small program that scans for a specific reusable Safari Net in an inventory next to the computer.
term.clear() term.setCursorPos(1,1) inventory = peripheral.wrap("left") inventory.condenseItems() print("Insert searched Net") typeS = io.read() function searchNet() maxCount = inventory.getInventorySize() for k = 1,maxCount do item = inventory.getStackInSlot(k) itemName = item.name if(itemName == "safarinet.reusable") then typeC = item.safari_net.captured end if(typeC == typeS) then print("Slot: "..k) break end end end searchNet()
So here's the problem:
If I run the program once, it works exactly as intended. It gives out the slot number of the searched
item and ends. But when i run it a second time it will always give out 1 as the slot number, no matter
if i change the item sequence or don't touch it at all. If I reboot the computer it works as intended again, but
only for the first time.