TG_Vulcano

ZenIa Utils

Aug 19th, 2025 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. -- v1
  2. -- load Config
  3. local config = require("config")
  4. local chat = peripheral.wrap(config.ai.chat)
  5. local owner = config.general.owner
  6.  
  7.  
  8. local UTILS = {}
  9.  
  10.  
  11. -- Gerador de Alertas (toast)
  12. function UTILS.msgAlerta(msg, source, title, user)
  13. title = title or "Zen"
  14. user = user or owner
  15. source = source or " "
  16.  
  17. local ok, err = chat.sendToastToPlayer(msg, title, user, source, "[]", "&c")
  18. if not ok then
  19. print("Erro ao enviar toast: " .. tostring(err))
  20. end
  21. end
  22.  
  23.  
  24. -- funçoes de texto em terminal
  25.  
  26. --Limpar tela
  27. function UTILS.clearScreen()
  28. term.clear()
  29. term.setCursorPos(1,1)
  30. end
  31.  
  32. -- Centraliza em X e Y (O meio do Meio hihihihihi)
  33. function UTILS.centerXY(txt)
  34. UTILS.clearScreen()
  35. local width, height = term.getSize()
  36. local x = math.floor((width - #txt) / 2) + 1
  37. local y = math.floor(height / 2)
  38. term.setCursorPos(x, y)
  39. print(txt)
  40. end
  41.  
  42. -- Centraliza na mesma linha
  43. function UTILS.center(txt, width)
  44. width = width or term.getSize()
  45. local padding = math.floor((width - #txt) / 2)
  46. if padding < 0 then padding = 0 end
  47. print(string.rep(" ", padding) .. txt)
  48. end
  49.  
  50.  
  51. return UTILS
Advertisement
Add Comment
Please, Sign In to add comment