voidbreath

selectItem

Apr 14th, 2020
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.52 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local robot = require("robot")
  4.  
  5. --selectItem
  6. function selectItem(name)
  7.   local item
  8.   for slot = 1, 16 do
  9.     print(slot)
  10.     item = component.inventory_controller.getStackInInternalSlot(slot)
  11.     if item ~= nil then
  12.       print(item["name"])
  13.     end
  14.     if item ~= nil and item.name == name then
  15.       print("found item")
  16.       robot.select(slot)
  17.       return true
  18.     end
  19.   end
  20.  
  21.   print("not found")
  22.   return false -- could not find item
  23. end
Advertisement
Add Comment
Please, Sign In to add comment