Advertisement
osmarks

PotatoUnplex

Sep 7th, 2019
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pcall(function() os.loadAPI "bigfont" end)
  2.  
  3. local OSes = {
  4.     "PotatOS",
  5.     "ShutdownOS",
  6.     "YomatOS",
  7.     "TomatOS",
  8.     "ChorOS",
  9.     "BurritOS",
  10.     "GovOS",
  11. }
  12.  
  13. local function random_pick(list)
  14.     return list[math.random(1, #list)]
  15. end
  16.  
  17. local function random_color()
  18.     return math.pow(2, math.random(0, 15))
  19. end
  20.  
  21. local function HSL(hue, saturation, lightness)
  22.     if hue < 0 or hue > 360 then
  23.         return 0x000000
  24.     end
  25.     if saturation < 0 or saturation > 1 then
  26.         return 0x000000
  27.     end
  28.     if lightness < 0 or lightness > 1 then
  29.         return 0x000000
  30.     end
  31.     local chroma = (1 - math.abs(2 * lightness - 1)) * saturation
  32.     local h = hue/60
  33.     local x =(1 - math.abs(h % 2 - 1)) * chroma
  34.     local r, g, b = 0, 0, 0
  35.     if h < 1 then
  36.         r,g,b=chroma,x,0
  37.     elseif h < 2 then
  38.         r,b,g=x,chroma,0
  39.     elseif h < 3 then
  40.         r,g,b=0,chroma,x
  41.     elseif h < 4 then
  42.         r,g,b=0,x,chroma
  43.     elseif h < 5 then
  44.         r,g,b=x,0,chroma
  45.     else
  46.         r,g,b=chroma,0,x
  47.     end
  48.     local m = lightness - chroma/2
  49.     return (r+m) * 16777216 + (g+m) * 65535 + (b+m) * 256
  50. end
  51.  
  52. local default_palette = { 0x000000, 0x7F664C, 0x57A64E, 0xF2B233, 0x3366CC, 0xB266E5, 0x4C99B2, 0x999999, 0x4C4C4C, 0xCC4C4C, 0x7FCC19, 0xDEDE6C, 0x99B2F2, 0xE57FD8, 0xF2B2CC, 0xFFFFFF }
  53. local palette = { 0x000000 }
  54. for i = 0, 13 do
  55.     table.insert(palette, HSL((i / 13) * 360, 1.0, 0.4))
  56. end
  57. table.insert(palette, 0xFFFFFF)
  58.  
  59. local function init_screen(t)
  60.     t.setTextScale(4)
  61.     t.setBackgroundColor(colors.black)
  62. --  t.setCursorPos(1, 1)
  63. --  t.clear()
  64.     for i, c in pairs(default_palette) do
  65.         t.setPaletteColor(math.pow(2, 16 - i), c)
  66.     end
  67. end
  68.  
  69. local function write_screen_slow(term, text, delay)
  70.     local w, h = term.getSize()
  71.     term.setCursorBlink(true)
  72.     for i = 1, #text do
  73.         local char = text:sub(i, i)
  74.         local x, y = term.getCursorPos()
  75.         term.write(char)
  76.         if x == w then
  77.             term.scroll(1)
  78.             term.setCursorPos(1, h)
  79.         end
  80.         sleep(delay)
  81.     end
  82.     term.setCursorBlink(false)
  83. end
  84.  
  85. local monitors = {peripheral.find("monitor", function(_, m) init_screen(m) return true end)}
  86.  
  87. local function unpotatoplexer()
  88.     while true do
  89.         local t = random_pick(monitors)
  90.         t.setTextColor(random_color())
  91.         if math.random(0, 1000) == 40 then
  92.             if bigfont then bigfont.writeOn(t, 1, "hello", 2, 2) end
  93.         else
  94.             write_screen_slow(t, random_pick(OSes) .. " ", 0.05)
  95.         end
  96.     end
  97. end
  98.  
  99. local threads = {}
  100. for i = 1, 5 do
  101.     table.insert(threads, unpotatoplexer)
  102. end
  103. parallel.waitForAll(unpack(threads))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement