Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tutils = {}
- function tutils.findItem(name)
- for i = 1, 16 do
- local item = turtle.getItemDetail(i)
- if item and item.name == name then
- return i
- end
- end
- end
- function tutils.selectItem(name)
- for i = 1, 16 do
- local item = turtle.getItemDetail(i)
- if item and item.name == name then
- turtle.select(i)
- end
- end
- end
- function tutils.selectEmptySlot()
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- turtle.select(i)
- return true
- end
- end
- return false
- end
- function tutils.selectFullSlot()
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return true
- end
- end
- return false
- end
- function tutils.getItemCount(name)
- local count = 0
- for i = 1, 16 do
- local item = turtle.getItemDetail(i)
- if item and item.name == name then
- count = count + item.count
- end
- end
- return count
- end
- return tutils
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement