Advertisement
Frayna

ShowIncome AE2

Jul 1st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local comp = require("component");
  2.  
  3. local  gpu = comp.gpu
  4. local  me = comp.me_controller
  5. local maxx, maxy = gpu.maxResolution()
  6.  
  7. --print(gpu.maxResolution)
  8. --print(maxx, maxy)
  9. --gpu.set(maxx / 2, maxy / 2, "pouet")
  10.  
  11. local arg = {...}
  12.  
  13. local delay
  14. if arg[2] then
  15. delay = arg[2]
  16. else
  17. delay = 1
  18. end
  19.  
  20. items = me.getItemsInNetwork()
  21. os.sleep(delay)
  22. items2 = me.getItemsInNetwork()
  23. --print("prout")
  24. local i = 0
  25. totalItems = items["n"]
  26. totalItems2 = items2["n"]
  27. items["n"], items2["n"] = nil
  28.  
  29. function swapKey(a,b, table)
  30.   local tmp = table[a]
  31.   table[a] = table[b]
  32.   table[b] = tmp
  33. end
  34.  
  35. function printTab(tab)
  36. for k,v in pairs(tab) do
  37. print(k,v)
  38. end
  39. end
  40.  
  41. function getDiff(items, items2)
  42.   diff = {}
  43.   for l,m in pairs(items) do
  44.     for k,v in pairs(items2) do
  45.       if m.name == v.name and m.size ~= v.size and m.label == v.label and l == k then
  46.         diff[m.label] = v.size - m.size
  47.       end
  48.     end
  49.   end
  50.   return diff
  51. end
  52.  
  53. diff = getDiff(items, items2)
  54.  
  55. printTab(diff)
  56.  
  57. function tablesort(tab)
  58.  
  59. for l,m in pairs(tab) do
  60.   for k,v in pairs(l) do
  61.     if m.size > v.size then
  62.       swapKey(l,k,tab)
  63.     end
  64.   end
  65. end
  66.  
  67. end
  68.  
  69. --tablesort(items)
  70.  
  71. function printTable(tableDouble)
  72. for k,v in pairs(items) do
  73.   print("--------------------")
  74.   print(k,v)
  75.   print("--------------------")
  76.   for x,y in pairs(v) do
  77.     print(x,y)
  78.   end
  79. end
  80. end
  81.  
  82. --printTable(items)
  83.  
  84. function showItem(name, tab)
  85. for k,v in pairs(tab) do
  86.   if v.label == name then
  87.   for i,j in pairs(v) do
  88.     print(i,j)
  89.   end
  90.   end
  91. end
  92. end
  93.  
  94. function showAll(name, tab)
  95. for k,v in pairs(tab) do
  96.   if string.find(string.lower(v.label), string.lower(name)) then
  97.   for i,j in pairs(v) do
  98.     print (i,j)
  99.   end
  100.   print("-----------------------")
  101.   end
  102. end
  103.  
  104. end
  105. --[[
  106. if arg[1] then
  107. --showItem(arg[1], items)
  108.   showAll(arg[1], items)
  109. end
  110. --]]
  111. --showItem("Cobblestone", items)
  112.  
  113. --printTable(items)
  114.  
  115.  
  116. -- Commentaires --
  117.  
  118.  
  119. --[[
  120.   print("____________________")
  121. for k,v in pairs(items[1757]) do
  122.   print(k,v)
  123. end--]]
  124.  
  125. --[[
  126. while(items[i]) do
  127.   print(items[i])
  128.   i = i + 1
  129. end
  130.    
  131.  
  132. for k,v in ipairs(items) do
  133.     print(k,v)
  134. end
  135. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement