Advertisement
Guest User

test

a guest
Jun 14th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. inv=peripheral.wrap("bottom")
  2. termXMax,termYMax=term.getSize()
  3. inv.condenseItems()
  4. function scanItems()
  5. slots=inv.getInventorySize()
  6. itemInSlot={}
  7. itemByName={}
  8. itemByNum={}
  9. itemById={}
  10. itemByAmount={}
  11. itemListed={}
  12. i2=1
  13. for i=1,slots do
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. term.write("Scan Slot"..tostring(i).." of "..tostring(slots))
  17. itemInSlot[i]=inv.getStackInSlot(i)
  18. sleep(0)
  19. if itemInSlot[i]~=nil then
  20. itemInSlot[i]["slot"]=i
  21. itemByName[itemInSlot[i]["name"]]=itemInSlot[i]
  22.  
  23. if itemById[itemInSlot[i]["id"]]==nil then
  24. itemByAmount[itemInSlot[i]["id"]]=itemInSlot[i]
  25. itemByNum[i2]=itemByAmount[itemInSlot[i]["id"]]
  26. i2=i2+1
  27. else
  28. itemByAmount[itemInSlot[i]["id"]]["qty"]=itemByAmount[itemInSlot[i]["id"]]["qty"]+itemInSlot[i]["qty"]
  29. end
  30. itemById[itemInSlot[i]["id"]]=itemInSlot[i]
  31. end
  32. end
  33. i=i2
  34. for i2=1,i-1 do
  35. itemByNum[i2]=itemByAmount[itemByNum[i2]["id"]]
  36. end
  37. end
  38.  
  39. function getItem(id,qty,slot)
  40. inv.pushIntoSlot("up",id,qty,slot)
  41. end
  42.  
  43. function itemAvarible(id,qty)
  44. itemAvarible=false
  45. if itemByAmount[id]~=nil then
  46. if itemByAmount[id]["qty"]>=qty then
  47. itemAvarible=true
  48. end
  49. end
  50. return itemAvarible
  51. end
  52.  
  53. scanItems()
  54. term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement