Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inv=peripheral.wrap("bottom")
- termXMax,termYMax=term.getSize()
- inv.condenseItems()
- function scanItems()
- slots=inv.getInventorySize()
- itemInSlot={}
- itemByName={}
- itemByNum={}
- itemById={}
- itemByAmount={}
- itemListed={}
- i2=1
- for i=1,slots do
- term.clear()
- term.setCursorPos(1,1)
- term.write("Scan Slot"..tostring(i).." of "..tostring(slots))
- itemInSlot[i]=inv.getStackInSlot(i)
- sleep(0)
- if itemInSlot[i]~=nil then
- itemInSlot[i]["slot"]=i
- itemByName[itemInSlot[i]["name"]]=itemInSlot[i]
- if itemById[itemInSlot[i]["id"]]==nil then
- itemByAmount[itemInSlot[i]["id"]]=itemInSlot[i]
- itemByNum[i2]=itemByAmount[itemInSlot[i]["id"]]
- i2=i2+1
- else
- itemByAmount[itemInSlot[i]["id"]]["qty"]=itemByAmount[itemInSlot[i]["id"]]["qty"]+itemInSlot[i]["qty"]
- end
- itemById[itemInSlot[i]["id"]]=itemInSlot[i]
- end
- end
- i=i2
- for i2=1,i-1 do
- itemByNum[i2]=itemByAmount[itemByNum[i2]["id"]]
- end
- end
- function getItem(id,qty,slot)
- inv.pushIntoSlot("up",id,qty,slot)
- end
- function itemAvarible(id,qty)
- itemAvarible=false
- if itemByAmount[id]~=nil then
- if itemByAmount[id]["qty"]>=qty then
- itemAvarible=true
- end
- end
- return itemAvarible
- end
- scanItems()
- term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement