Clem105

Chest

Feb 21st, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local Name = " "
  2. local Data = {}
  3. local qty = 0
  4. local chest = peripheral.wrap("top")
  5. local monitor = peripheral.wrap("right")
  6. monitor.clear()
  7. local Size = chest.getInventorySize()
  8.  
  9. function FillData()
  10.     for i=1,Size do
  11.         Data[i] = {}
  12.         if chest.getStackInSlot(i) ~= nil then
  13.             for k,v in pairs(chest.getStackInSlot(i)) do
  14.                     Data[i][k] = v
  15.             end
  16.         end
  17.     end
  18. end
  19.  
  20. function GetQty()
  21.     for i=1,Size do
  22.         if Data[i]["name"] == Name then
  23.             qty = qty+Data[i]["qty"]
  24.         end
  25.     end
  26. end
  27.  
  28. while true do  
  29.     FillData()
  30.     GetQty()
  31.     monitor.clear()
  32.     monitor.setTextScale(5)
  33.     monitor.write("Nombre de "..Name.." : "..qty)
  34.     qty = 0
  35.     sleep(2)
  36. end
Advertisement
Add Comment
Please, Sign In to add comment