Advertisement
Oleshe

Multi Screen

Feb 8th, 2023 (edited)
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.40 KB | None | 0 0
  1. local fs = require('filesystem')
  2. local multiplescreen = {}
  3. local curmon = '557'
  4. local mon = {}
  5. local image = require('image')
  6. local gpu = require('component').gpu
  7. local monitors = {'a05','b77','6d1','917','7a6','7b1','17a','10d','de3','a92','000','0fd','47e','ca0','0d7','b29','d35','b4b','b1e','902','4fc','4b8','31f','82a','05b','d6f','4ee','79b','518','c7a'}
  8. for i =1,6 do
  9.   mon[i] = {}
  10.   for s =1,5 do
  11.     mon[i][s] = {}
  12.   end
  13. end
  14. function get(address,CT)
  15.   for c in require('component').list(CT,true) do
  16.     if c:sub(1,address:len()) == address then
  17.        return c
  18.     end
  19.   end
  20. end
  21. i = 0
  22. e = 0
  23. x = 0
  24. toend = {}
  25. s = 0
  26. while x < 126*6 do
  27.   x = x + 126
  28.   i = i + 1
  29.   toend[i] = {}
  30.   y = 0
  31.   e = 0
  32.   while y < 63 * 5 do
  33.     y = y + 63
  34.     e = e + 1
  35.     s = s + 1
  36.     toend[i][e] = monitors[s]
  37.   end
  38. end
  39. local function set(idk)
  40.   local symbol,_,bg = gpu.get(idk[1],idk[2])
  41.   if bg == idk[3] then
  42.     if symbol == idk[5] then
  43.       print('skip')
  44.       return
  45.     end
  46.     if symbol == ' ' then
  47.       print('skip trans')
  48.       return
  49.     else
  50.       print('skip trans any')
  51.       gpu.setForeground(idk[4])
  52.       gpu.set(idk[1],idk[2],idk[5])
  53.       return
  54.     end
  55.   end
  56.   gpu.setForeground(idk[4])
  57.   gpu.setBackground(idk[3])
  58.   local toend = gpu.set(idk[1],idk[2],idk[5])
  59.   return toend
  60. end
  61. function multiplescreen.draw(x1,y1,path)
  62.   if type(path) == 'string' then
  63.     if fs.exists(path) then
  64.      print('load')
  65.      imagee =  image.load(path)
  66.      else
  67.      return
  68.      end
  69.   else
  70.     print('use')
  71.     local imagee = path
  72.   end
  73.   local turn = 0
  74.   local turnbool = false
  75.   local w = imagee[1]
  76.   local h = imagee[2]
  77.   print(w,h)
  78.   for x = 1,w do
  79.     for y = 1,h do
  80.       local bg,fg,_,symbol = image.get(imagee,x,y)
  81.     local x = x + x1 - 1
  82.     local y = y + y1 -1
  83.     local xx = math.ceil(x / 126)
  84.     local yy = math.ceil(y / 63)
  85.     local localX = x - (xx - 1) * 126
  86.     local localY = y - (yy - 1) * 63
  87.     print('pixel')
  88.     if xx > 6 then
  89.     print(xx,yy,w,h,x1,y1,x,y)
  90.     end
  91.     table.insert(mon[xx][yy],{localX,localY,bg,fg,symbol})
  92.     end
  93.   end
  94.   print('draw')
  95.   for x = 1,6 do
  96.     for y = 1,5 do
  97.     if mon[x][y] ~= {} then
  98.     gpu.bind(get(toend[x][y]),false)
  99.     gpu.setDepth(8)
  100.     gpu.setResolution(126,63)
  101.       for i=1,#mon[x][y] do
  102.         set(mon[x][y][i])
  103.       end
  104.     end end
  105.   end
  106.   gpu.bind(get('a73'))
  107. end
  108. return multiplescreen
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement