MaLittlePwny

Untitled

Sep 23rd, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. function sortByAmount(x, y)
  2. return x.amount > y.amount
  3. end
  4.  
  5. function checkAmount(itemList)
  6. for key,value in pairs (itemList) do
  7. itemList[key].amount = lp.getItemAmount(itemList[key].id)
  8. if (key%100 == 0) then
  9. sleep(0.00000000000000000000000000000001)
  10. end
  11. end
  12. end
  13.  
  14. function updateDisplay()
  15. monX = 1
  16. monY = 1
  17. mon.clear()
  18. for i = 1, 208,1 do
  19. name = itemList[i].name
  20. amount = itemList[i].amount
  21. mon.setCursorPos(monY, monX)
  22. mon.write(name)
  23. mon.setCursorPos(monY+28-6,monX)
  24. mon.write(": ")
  25. amountString = tostring(amount)
  26. mon.setCursorPos(monY+28-string.len(amountString),monX)
  27. mon.write(amountString)
  28. monX = monX+1
  29. if monX == 53 then
  30. monX = 1
  31. monY = monY+31
  32. end
  33. end
  34. end
  35.  
  36. lp = peripheral.wrap("bottom")
  37. mon = peripheral.wrap("top")
  38. mon.setTextScale(0.5)
  39. mon.clear()
  40. itemList={}
  41.  
  42. n=1
  43. myList = lp.getAvailableItems()
  44. print(#myList)
  45. print("import started")
  46. for key,value in pairs( myList ) do
  47. z = myList[key]
  48. id = z[1]
  49. itemList[n] = {}
  50. itemList[n].id = id
  51. itemList[n].name = lp.getUnlocalizedName(itemList[key].id)
  52. n= n+1
  53. end
  54. while true do
  55. print("getAmount")
  56. checkAmount(itemList)
  57. print("import done")
  58. table.sort(itemList, sortByAmount)
  59. print("updateDisplay")
  60. updateDisplay()
  61. sleep(2)
  62. end
Add Comment
Please, Sign In to add comment