Advertisement
Guest User

cache2

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