Advertisement
RabaGhast

checkChest

Nov 17th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. term.setTextColor(colors.green)
  2. term.write("v0.4")
  3. term.setTextColor(colors.white)
  4. names = {"gold", "iron"}
  5. chest = peripheral.wrap("bottom")
  6.  print("")
  7.  
  8.  
  9. function checkChest()
  10.  
  11.   items = {}
  12.   qty = {}
  13.   for i = 1,chest.getInventorySize() do
  14.     item =  chest.getStackInSlot(i)
  15.     if item ~= nil then
  16.       for j = 1,#names do
  17.         if string.match(item["name"], names[j]) then
  18.           items[#items+1] = item["name"]
  19.           qty[#qty+1] = item["qty"]
  20.           break
  21.         end
  22.       end
  23.     end
  24.   end
  25. return items, qty
  26. end
  27.  
  28. items, qty = checkChest()
  29.  
  30. for i=1,#items do
  31.   print(qty[i].." "..items[i])
  32. end
  33.  
  34.  
  35. ---------------------------------------------------------------------------------------
  36.  
  37.  
  38. function tellNames()
  39.   for i = 1,chest.getInventorySize() do
  40.     item =  chest.getStackInSlot(i)
  41.     print(item["name"]..", "..item["display_name"]..", "..item["raw_name"]..", "..item["mod_id"])
  42.   end
  43. end
  44.  
  45.  
  46. --[[
  47.  
  48. pastebin get 5yu5bhR3
  49.  
  50. for i,v in pairs(someItem) do
  51.   print(i..", "..v)            prints eg. "display_name, Crafting Table", "qty, 2", "max_size, 64"
  52. end
  53. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement