TG_Vulcano

Zenia IA

Aug 19th, 2025 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. -- Load Configs
  2. local config = require("config")
  3. local effects = require("modules.pylons")
  4. local utils = require("modules.utils")
  5.  
  6. -- Peripheral
  7. local chat = peripheral.wrap(config.ai.chat)
  8.  
  9. -- Config
  10. local commandPrefix = config.ai.name
  11. local owner = config.general.owner
  12.  
  13. -- Dicionário de comandos
  14. local commands = {
  15. ["add"] = {
  16. func = function(args)
  17. if not args[1] then
  18. utils.msgAlerta("Especifique um efeito para ativar.", "&bPylons")
  19. return
  20. end
  21. effects.ativarEfeito(args[1])
  22. end
  23. },
  24. ["rem"] = {
  25. func = function(args)
  26. if not args[1] then
  27. msgAlerta("Especifique um efeito para remover.", "&bPylons")
  28. return
  29. end
  30. effects.removerEfeito(args[1])
  31. end
  32. },
  33. ["clear"] = {
  34. func = function(args)
  35. effects.limparPylon()
  36. end
  37. }
  38. }
  39.  
  40. -- Função para processar comandos
  41. local function handleCommand(message, player)
  42. local prefixlen = #commandPrefix
  43.  
  44. -- Só processa se a mensagem começar com o prefixo
  45. if message:lower():sub(1, prefixlen + 1) == commandPrefix:lower() .. " " then
  46. -- Se não for o dono, avisa
  47. if player ~= owner then
  48. utils.msgAlerta("Curioso morre cedo no Rio", "&cZen", nil, player)
  49. return false
  50. end
  51.  
  52. -- Remove o prefixo da mensagem
  53. local text = message:sub(prefixlen + 2):lower()
  54.  
  55. -- Divide em palavras
  56. local words = {}
  57. for word in text:gmatch("%S+") do
  58. table.insert(words, word)
  59. end
  60.  
  61. local cmd = words[1]
  62. local args = {}
  63. for i = 2, #words do
  64. table.insert(args, words[i])
  65. end
  66.  
  67. -- Executa comando
  68. if cmd and commands[cmd] and type(commands[cmd].func) == "function" then
  69. commands[cmd].func(args)
  70. return true
  71. else
  72. utils.msgAlerta("Comando desconhecido ou inválido: " .. tostring(cmd), "&cZen")
  73. end
  74. end
  75. return false
  76. end
  77.  
  78. -- Loop principal
  79. utils.centerXY("ZEN !IA")
  80. while true do
  81. local event, player, message = os.pullEvent("chat")
  82. handleCommand(message, player)
  83. end
  84.  
Advertisement
Add Comment
Please, Sign In to add comment