Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get the number of empty slots in inventory
- function getInvNumEmptySlots()
- local slots = 0
- -- FIXME TODO: check for auto-refuel enabled
- local lastSlot = 16
- for i = 1, lastSlot do
- if turtle.getItemCount(i) == 0 then
- slots = slots + 1
- end
- end
- return slots
- end
- -- Get the number of items in inventory
- function getInvNumItems()
- local num = 0
- -- FIXME TODO: check for auto-refuel enabled
- local lastSlot = 16
- for i = 1, lastSlot do
- num = num + turtle.getItemCount(i)
- end
- return num
- end
- -- Get the number of items that can be added into inventory
- function getInvFreeSpace()
- local fs = 0
- -- FIXME TODO: check for auto-refuel enabled
- local lastSlot = 16
- for i = 1, lastSlot do
- fs = fs + turtle.getItemSpace(i)
- end
- return fs
- end
- -- Loop through the inventory
- function invLoop()
- -- FIXME TODO: check for auto-refuel enabled
- local lastSlot = 16
- for i = 1, lastSlot do
- turtle.select(i)
- end
- return true
- end
- -- Compare the block to each slot in inventory
- function compareToInv()
- -- FIXME TODO: check for auto-refuel enabled
- local lastSlot = 16
- for i = 1, lastSlot do
- turtle.select(i)
- if turtle.compare() == true then
- print("Block matches!")
- break
- end
- end
- return true
- end
- print("Before...")
- print("getInvNumEmptySlots(): " .. getInvNumEmptySlots() )
- print("After...")
- print("Before...")
- print("getInvFreeSpace(): " .. getInvFreeSpace() )
- print("After...")
- print("Before...")
- print("getInvNumItems(): " .. getInvNumItems() )
- print("After...")
- print("Before...")
- invLoop()
- print("invLoop()")
- print("After...")
- print("Before...")
- compareToInv()
- print("compareToInv()")
- print("After...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement