Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- imgHeight = 16
- if fs.exists("imgs.txt") then
- imgs = paintutils.loadImage("imgs.txt")
- else
- shell.run("pastebin get dNXpareS imgs.txt")
- --Assumes you have http enabled
- imgs = paintutils.loadImage("imgs.txt")
- end
- if fs.exists("names") then
- else
- shell.run("pastebin get 9d4JPVYB names")
- --Assumes you have http enabled
- end
- local names = {}
- names = readLines("names")
- local rangeLow = 1 --Change to be 1-8, 9-16, 17-24 etc.
- local rangeHigh = 8
- local function readLines(sPath)
- local file = fs.open(sPath, "r")
- if file then
- local tLines = {}
- local sLine = file.readLine()
- while sLine do
- table.insert(tLines, sLine)
- sLine = file.readLine()
- end
- file.close()
- return tLines
- end
- return nil
- end
- function drawImg(index, x,y)
- index = index - 1
- curY = 0
- for yy = index*imgHeight+1, (index+1)*imgHeight do
- for xx = 1, 16 do
- paintutils.drawPixel(x+xx-1, y+curY, imgs[yy][xx])
- end
- curY = curY + 1
- end
- end
- function renderAspect(name, qty, x, y)
- local index = 0
- for i = 1, #names do
- if string.lower(name) == string.lower(names[i]) then
- index = i
- break
- end
- end
- if index ~= 0 then
- drawImg(index, x,y)
- utils.write(x+1, y + imgHeight, name .. ": " .. qty, colors.white, colors.black)
- return 1
- else
- return 0
- end
- end
- mon = peripheral.wrap("right")
- term.redirect(mon)
- term.clear()
- rednet.open("bottom")
- local globalTbl = {}
- utils = {
- clear = function()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- end,
- write = function(x, y, text, color, background)
- if color ~= nil then
- mon.setTextColor(color)
- else
- mon.setTextColor(colors.white)
- end
- if background ~= nil then
- mon.setBackgroundColor(background)
- else
- mon.setBackgroundColor(colors.black)
- end
- mon.setCursorPos(x, y)
- mon.write(text)
- end,
- writeCentered = function(y, text, color, background)
- utils.write(utils.centerString(text), y, text, color, background)
- end,
- getWidth = function()
- local width, height = mon.getSize()
- return width
- end,
- getHeight = function()
- local width, height = mon.getSize()
- return height
- end,
- centerString = function(msg)
- local length = string.len(msg)
- local width = utils.getWidth()
- return (width - length) / 2
- end
- }
- function printAspects()
- utils.clear()
- utils.writeCentered(1," Cauldron ", colors.white, colors.blue)
- if globalTbl ~= nil then
- local t = {}
- for k, v in pairs(globalTbl) do
- if v ~= nil then
- for k2, v2 in pairs(v) do
- if t[k2] ~= nil then
- t[k2] = t[k2] + v2
- else
- t[k2] = v2
- end
- end
- end
- end
- line = 3
- local a = {}
- for n in pairs(t) do
- table.insert(a,n)
- end
- table.sort(a)
- xs = {1, 21, 42, 63, 1, 21,42,63}
- ys = {1, 1, 1, 1, 19, 19,19,19}
- line = 1
- local tempMax = rangeHigh
- if rangeHigh > #a then
- tempMax = #a
- end
- for i = rangeLow, tempMax do
- -- utils.write(1, line, v .. ": " .. t[v])
- v = a[i]
- renderAspect(v, t[v], xs[line], ys[line]+2)
- line = line + 1
- end
- end
- end
- function main()
- while true do
- id, msg = rednet.receive()
- utils.clear()
- if not (msg == "none") then
- tbl = textutils.unserialize(msg)
- globalTbl[id] = tbl
- i = 0
- else
- globalTbl[id] = nil
- end
- printAspects()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement