Advertisement
krakaen

testing stuff and things 2nd

Feb 20th, 2019
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. ---- END FUNCTIONS
  2.  
  3. function getItemInfoFromStorate(item, storage)
  4.     local size = storage.size()
  5.     local itemList = storage.list()
  6.     local positions = {}
  7.     local nbrOfItems = 0
  8.     modName, itemName, itemDamage = item:match("(%w+):(%w+):?(%w+)?")  
  9.     if itemDamage == nil then
  10.         itemDamage = "0"
  11.     end
  12.     for i = 1,size,1 do
  13.         if itemList[i] ~= nil then
  14.             if itemList[i]["name"] == modName .. ":" .. itemName and tostring(itemList[i]["damage"]) == itemDamage then
  15.                 table.insert(positions, i)
  16.                 nbrOfItems = nbrOfItems + itemList[i]["count"]
  17.                
  18.             end
  19.         end
  20.     end
  21.     return {positions = positions, nbrOfItems = nbrOfItems}
  22. end
  23.  
  24. local stuff = getItemInfoFromStorate("botania:livingrock:1", peripheral.wrap("right"))
  25.  
  26. write (stuff.positions[1], nbrOfItems)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement