Reavik

DisplayLoja

Jan 10th, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | Gaming | 0 0
  1. local mon = peripheral.find("monitor")
  2. local W, H = mon.getSize()    -- W = Largura | H = Altura
  3.  
  4.  
  5. local scale = 1
  6.  
  7. -- Pode colocar a cor ou deixar sem para ficar aleatΓ³rio
  8. local staticTexts = {
  9.     {txt = "  BEM VINDO!", y = 1, color = colors.red},
  10.     {txt = "===============================", y = 3},
  11.     {txt = "===============================", y = 5},
  12.     {txt = "===============================", y = 7},
  13.     {txt = "  >>>Aproveite<<<", y = 9},
  14.     {txt = "  <-- Vanilla | Mods -->", y = 10},
  15. }
  16.  
  17. local roundTexts = {
  18.     {txt = "  Teste teste teste teste teste teste", y = 4},
  19.     {txt = "  Todos os ingots do modpack", y = 6},
  20.     {txt = "  Aproveite", y = 8},
  21. }
  22.  
  23.  
  24.  
  25. mon.setTextScale(scale)
  26.  
  27. local function moveFirstToLast(str)
  28.     local first = string.sub(str, 1, 1)
  29.     local rest = string.sub(str, 2)
  30.     return rest .. first
  31. end
  32.  
  33. local function staticColoredTexts()
  34.     for _,v in pairs(staticTexts) do
  35.         local x = math.floor((W - string.len(v.txt)) / 2)
  36.         local color = v.color or math.random(1,16)
  37.         mon.setTextColor(color)
  38.         mon.setCursorPos(x, v.y)
  39.         mon.write(v.txt)
  40.     end
  41. end
  42.  
  43. local function roundColoredTexts()
  44.     for _,v in pairs(roundTexts) do
  45.         v.txt = moveFirstToLast(v.txt)
  46.         local x = math.floor((W - string.len(v.txt)) / 2)
  47.         local color = v.color or math.random(1,16)
  48.  
  49.         mon.setTextColor(color)
  50.         mon.setCursorPos(x, v.y)
  51.         mon.clearLine()
  52.         mon.write(v.txt)
  53.     end
  54. end
  55.  
  56. while true do
  57.     mon.clear()
  58.  
  59.     roundColoredTexts()
  60.  
  61.     staticColoredTexts()
  62.  
  63.     sleep(0.4)
  64. end
  65.  
Add Comment
Please, Sign In to add comment