Advertisement
HangMan23

ScreenBackup.lua

Mar 19th, 2019
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local func = table.unpack({...})
  2.  
  3. local gpu = require("component").gpu
  4.  
  5. local w, h = gpu.getResolution()
  6.  
  7. local scr = {}
  8.  
  9. for i = 1, w do
  10.  
  11.   scr[i] = {}
  12.  
  13.   for j = 1, h do
  14.  
  15.     scr[i][j] = {gpu.get(i, j)}
  16.  
  17.   end
  18.  
  19. end
  20.  
  21. func()
  22.  
  23. for i = 1, w do
  24.  
  25.   for j = 1, h do
  26.  
  27.     local symbol = {gpu.get(i, j)}
  28.  
  29.     if symbol[1] ~= scr[i][j][1] or symbol[2] ~= scr[i][j][2] or symbol[3] ~= scr[i][j][3] then
  30.  
  31.       if gpu.getBackground ~= scr[i][j][3] then gpu.setBackground(scr[i][j][3]) end
  32.       if gpu.getForeground ~= scr[i][j][2] then gpu.setForeground(scr[i][j][2]) end
  33.  
  34.       gpu.set(i, j, scr[i][j][1])
  35.  
  36.     end
  37.  
  38.   end
  39.  
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement