Advertisement
sosochka

artSubsDisplay

Jun 17th, 2022 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. local function syncImages()
  2.     while true do
  3.         local id, message = rednet.receive()
  4.         if id and message.protocol == "Input" then
  5.             local newImage = io.open("images/" .. message.name, "w")
  6.             newImage.write(newImage, message.data)
  7.             newImage.close(newImage)
  8.         elseif id and message.protocal == "Delete" then
  9.             fs.delete("images/" .. message.name)
  10.         end
  11.     end
  12. end
  13.  
  14. local function main()
  15.     local width, height = term.getSize()
  16.  
  17.     while true do
  18.         local images = fs.list("/images/")
  19.         for k in pairs(images) do
  20.             term.setBackgroundColor(colors.black)
  21.             term.clear()
  22.             local img = paintutils.loadImage("images/" .. images[k])
  23.             if img then
  24.                 paintutils.drawImage(img, 5, 4)
  25.                 term.setCursorPos(width / 2 - (string.len(images[k]) / 2), 2)
  26.                 term.setBackgroundColor(colors.white)
  27.                 term.setTextColor(colors.black)
  28.                 term.write(string.sub(images[k], 1, -5))
  29.                 sleep(3)
  30.             end
  31.         end
  32.     end
  33. end
  34.  
  35. --Setting up the terminal and the monitor
  36. term.clear()
  37. term.setCursorPos(1, 1)
  38. term.write("The TV is working")
  39.  
  40. local monitor = peripheral.wrap("top")
  41. monitor.clear()
  42. term.redirect(monitor)
  43. monitor.setTextScale(0.5)
  44.  
  45. rednet.open("left")
  46.  
  47. parallel.waitForAny(syncImages, main)
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement