Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- mem.count: count per item type
- -- mem.list: list of item types
- -- mem.total: total number of items counted
- local ControlPanel = "panel"
- local send = function()
- local line = ""
- for i = 1, 5 do
- local name = mem.list[mem.pointer + i]
- if not name then break end
- line = line .. tostring(mem.count[name]) .. " " .. name .. "\n"
- end
- digiline_send(ControlPanel, line .. "Page: " .. tostring(math.floor(mem.pointer / 5)) .. "/" .. tostring(math.floor(#mem.list / 5)) .. " Heat: " .. tostring(heat))
- end
- if event.type == "digiline" then
- local msg = event.msg
- if event.channel == "incoming" then
- if mem.count[msg] then
- mem.count[msg] = mem.count[msg] + 1
- else
- mem.count[msg] = 1
- table.insert(mem.list, msg)
- end
- mem.total = mem.total + 1
- send()
- elseif event.channel == ControlPanel then
- if msg == "up" then
- mem.pointer = math.max(mem.pointer - 1, 0)
- send()
- elseif msg == "down" then
- mem.pointer = math.min(mem.pointer + 1, #mem.list)
- send()
- end
- end
- elseif event.type == "program" then
- mem.count = mem.count or {}
- mem.list = mem.list or {}
- mem.pointer = mem.pointer or 0
- mem.total = mem.total or 0
- send()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement