Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m1 = peripheral.wrap("monitor_37")
- m2 = peripheral.wrap("monitor_38")
- function getList()
- lijst = {}
- jars = peripheral.getNames()
- for k, v in pairs(jars) do
- if (v ~= "right" and v ~= "left" and v ~= "container_chest_0" and v ~= "monitor_38" and v ~= "monitor_37") then
- aspects = peripheral.call(v,"getAspects")
- aspect = aspects[1]
- if #lijst == 0 then
- table.insert(lijst,aspect)
- else
- found = false
- foundIndex = 0
- for i = 1, #lijst do
- if lijst[i].name == aspect.name then
- found = true
- foundIndex = i
- end
- end
- if found then
- lijst[foundIndex].quantity = lijst[foundIndex].quantity + aspect.quantity
- else
- table.insert(lijst,aspect)
- end
- end
- end
- end
- sort_func = function( a,b ) return a.name < b.name end
- table.sort( lijst, sort_func )
- return lijst
- end
- function draw(m,y,aspect)
- mx, my = m.getSize()
- m.setBackgroundColor(colors.black)
- ypos = y
- xpos = 2
- if y > 12 then
- ypos = y - 12
- xpos = (mx/2)
- end
- m.setCursorPos(xpos,(ypos*2))
- m.write(aspect.name)
- m.setCursorPos(xpos+13,(ypos*2))
- m.setBackgroundColor(colors.orange)
- amount = math.ceil((aspect.quantity/(5*64))*((mx/2)-16))
- for i = 1, amount do
- m.write(" ")
- end
- m.setCursorPos(xpos+14,(ypos*2))
- m.write(tostring(aspect.quantity))
- end
- os.startTimer(5)
- oldlist = getList()
- newlist = oldlist
- while true do
- os.pullEvent("timer")
- oldlist = newlist
- newlist = getList()
- m1.setBackgroundColor(colors.black)
- m2.setBackgroundColor(colors.black)
- m1.clear()
- m2.clear()
- changed = false
- for i = 1, #newlist do
- if newlist[i].quantity ~= oldlist[i].quantity then
- changed = true
- end
- if i < 25 then
- draw(m1,i,newlist[i])
- else
- draw(m2,i-24,newlist[i])
- end
- end
- if changed then
- print("Something changed")
- os.startTimer(5)
- else
- print("Nothing changed")
- os.startTimer(30)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement