Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sort_by_amount(x, y)
- return x.amount > y.amount
- end
- function get_items()
- local available_items = a.getAvailableItems()
- local item_list = {}
- local n = 1
- print(#available_items)
- for key,value in pairs( available_items ) do
- local z = available_items[key]
- local id = z[1]
- item_list[n] = {}
- item_list[n].id = id
- item_list[n].name = id --string.sub(getUnlocalizedName(item_list[key].id),1,20)
- item_list[n].amount = a.getItemAmount(item_list[key].id)
- if (key%10 == 0) then
- sleep(0.05)
- end
- n= n+1
- end
- table.sort(item_list, sort_by_amount)
- return item_list
- end
- function display_items(item_list)
- monX = 1
- monY = 2
- mon.clear()
- for i = 1, total_items_to_display,1 do
- name = item_list[i].name
- amount = item_list[i].amount
- mon.setCursorPos(monY, monX)
- mon.write(name)
- mon.setCursorPos(monY+21,monX)
- mon.write(": ")
- amount_string = tostring(amount).." |"
- mon.setCursorPos(monY+30-string.len(amount_string),monX)
- mon.write(amount_string)
- if monX == items_to_display_per_row then
- monX = 0
- monY = monY+30
- end
- monX = monX+1
- end
- end
- function main()
- while true do
- item_list = get_items()
- display_items(item_list)
- sleep(10)
- end
- end
- function boot()
- iteration = 1
- a = peripheral.wrap(a_direction)
- mon = peripheral.wrap(mon_direction)
- mon.setTextScale(0.5)
- mon.clear()
- mon.setTextScale(0.5)
- mon.setCursorPos(34,26)
- mon.write("AE display system booting up, stand by...")
- mon.setCursorPos(36,32)
- end
- items_to_display_per_row = 52
- total_items_to_display = 208
- a_direction = "back"
- mon_direction = "top"
- boot()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement