Advertisement
Oleshe

Image Slave

Feb 11th, 2023 (edited)
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. local function get(address,CT)
  2.   for c in require('component').list(CT,true) do
  3.     if c:sub(1,address:len()) == address then
  4.        return c
  5.     end
  6.   end
  7. end
  8. local cmp = component
  9. local modem = cmp.proxy(cmp.list("modem")())
  10. local gpu = cmp.proxy(cmp.list("gpu")())
  11. modem.open(1)
  12. gpu.bind(cmp.list('screen')(),false)
  13. gpu.setResolution(126,63)
  14. gpu.setDepth(8)
  15. gpu.fill(1,1,126,63,' ')
  16. local function set(idk)
  17.   gpu.setForeground(idk[4])
  18.   gpu.setBackground(idk[3])
  19.   return gpu.set(idk[1],idk[2],idk[5])
  20. end
  21. local iM = false
  22.  
  23. modem.broadcast(1,'get',' ',' ')
  24. local exit = false
  25. gpu.set(1,1,'Wait For Address...')
  26. while exit == false  do
  27.   local name, _, _, _, _, x, y  =computer.pullSignal(1)
  28.   if name == 'modem_message' then
  29.     monitorx = tonumber(x)
  30.     monitory = tonumber(y)
  31.     exit = true
  32.   end
  33. end
  34. exit = nil
  35. if monitorx == 6 then
  36.   if monitory == 5 then
  37.     iM = true
  38.   end
  39. end
  40.  
  41. while true do
  42.   local name, _, _, _, _, x, y,e3,e4 =computer.pullSignal(1)
  43.   if name == 'modem_message' then
  44.     gpu.set(1,1,x..' '..y..' '..e3..' '..monitorx..' '..monitory)
  45.     if tostring(x) == 'get' then
  46.       if iM == false then
  47.         iM = true
  48.         y = monitory
  49.         x = monitorx + 1
  50.         if x > 6 then
  51.           x = 1
  52.           y = monitory + 1
  53.         end
  54.         modem.broadcast(1,x,y)
  55.       end
  56.     end
  57.     if tonumber(x) == monitorx then
  58.       if tonumber(y) == monitory then
  59.         if e3 == 'set' then
  60.           if e3 then
  61.             gpu.fill(1,1,126,63,' ')
  62.             gpu.set(1,3,'draw')
  63.             load(e3)()
  64.             for i=1,#mon do
  65.               set(mon[i])
  66.             end
  67.           end
  68.         end
  69.         if e3 == 'clear' then
  70.           gpu.fill(1,1,126,63,' ')
  71.         end
  72.       end
  73.     end
  74.   end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement