Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sortByAmount(x, y)
- return x.amount > y.amount
- end
- function checkAmount(itemList)
- for key,value in pairs (itemList) do
- itemList[key].amount = lp.getItemAmount(itemList[key].id)
- if (key%100 == 0) then
- sleep(0.00000000000000000000000000000001)
- end
- end
- end
- function updateDisplay()
- monX = 1
- monY = 1
- mon.clear()
- for i = 1, 208,1 do
- name = itemList[i].name
- amount = itemList[i].amount
- mon.setCursorPos(monY, monX)
- mon.write(name)
- mon.setCursorPos(monY+28-6,monX)
- mon.write(": ")
- amountString = tostring(amount)
- mon.setCursorPos(monY+28-string.len(amountString),monX)
- mon.write(amountString)
- monX = monX+1
- if monX == 53 then
- monX = 1
- monY = monY+31
- end
- end
- end
- lp = peripheral.wrap("bottom")
- mon = peripheral.wrap("top")
- mon.setTextScale(0.5)
- mon.clear()
- itemList={}
- n=1
- myList = lp.getAvailableItems()
- print(#myList)
- print("import started")
- for key,value in pairs( myList ) do
- z = myList[key]
- id = z[1]
- itemList[n] = {}
- itemList[n].id = id
- itemList[n].name = lp.getUnlocalizedName(itemList[key].id)
- n= n+1
- end
- while true do
- print("getAmount")
- checkAmount(itemList)
- print("import done")
- table.sort(itemList, sortByAmount)
- print("updateDisplay")
- updateDisplay()
- sleep(2)
- end
Add Comment
Please, Sign In to add comment