Vodka51200

monitorscancache 1.7.10

Jun 21st, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. local p = {peripheral.find("powered_tile")}
  2. local mon = peripheral.find("monitor")
  3.  
  4. Max = m.getMaxStoredItems()
  5.  
  6. mon.setBackgroundColor(colors.cyan)
  7. mon.setTextColor(colors.black)
  8. mon.clear()
  9. mon.setTextScale(1)
  10. local w, h = mon.getSize()
  11. while true do
  12.   local aff = {}
  13.   local function nWrite(x,y,txt)
  14.     aff[y] = aff[y] or {}
  15.     aff[y][x]=txt
  16.   end
  17.   local x = 1
  18.   local div = math.ceil(#p/h)
  19.   local s=math.floor(w/(div)+0.5)
  20.   for j=1, #p, h do
  21.     for i=1, h do
  22.       if p[i+j-1] then
  23.         local v = p[i+j-1]
  24.         local item = v.getStoredItems()
  25.         if item ~= nil then
  26.           nWrite(x,i,(i+j-1).."- "..item.display_name.." x"..(item.qty==v.getMaxStoredItems() and "Full" or item.qty))
  27.         else
  28.           nWrite(x,i,(i+j-1).."- vide")
  29.         end
  30.       end
  31.     end
  32.     x=x+s
  33.   end
  34.   for y=1, #aff do
  35.     mon.setCursorPos(1,y)
  36.     mon.clearLine()
  37.     for x, txt in pairs(aff[y]) do
  38.       mon.setCursorPos(x,y)
  39.       mon.write(txt)
  40.     end
  41.   end
  42.   sleep(0.1)
  43. end
  44.  
  45. --while true do
  46. --  items = p.getStoredItems()
  47. --  term.setBackgroundColor(colors.black)
  48. -- term.clear()
  49. --  term.setCursorPos(1,1)
  50. --  print(term.getSize())
  51. --  paintutils.drawFilledBox(2,3,49,3,colors.gray)
  52. --  paintutils.drawFilledBox(2,3,math.ceil(items.qty*49/Max),3,colors.green)
  53. --end
Add Comment
Please, Sign In to add comment