Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load Configs
- local config = require("config")
- local effects = require("modules.pylons")
- local utils = require("modules.utils")
- -- Peripheral
- local chat = peripheral.wrap(config.ai.chat)
- -- Config
- local commandPrefix = config.ai.name
- local owner = config.general.owner
- -- Dicionário de comandos
- local commands = {
- ["add"] = {
- func = function(args)
- if not args[1] then
- utils.msgAlerta("Especifique um efeito para ativar.", "&bPylons")
- return
- end
- effects.ativarEfeito(args[1])
- end
- },
- ["rem"] = {
- func = function(args)
- if not args[1] then
- msgAlerta("Especifique um efeito para remover.", "&bPylons")
- return
- end
- effects.removerEfeito(args[1])
- end
- },
- ["clear"] = {
- func = function(args)
- effects.limparPylon()
- end
- }
- }
- -- Função para processar comandos
- local function handleCommand(message, player)
- local prefixlen = #commandPrefix
- -- Só processa se a mensagem começar com o prefixo
- if message:lower():sub(1, prefixlen + 1) == commandPrefix:lower() .. " " then
- -- Se não for o dono, avisa
- if player ~= owner then
- utils.msgAlerta("Curioso morre cedo no Rio", "&cZen", nil, player)
- return false
- end
- -- Remove o prefixo da mensagem
- local text = message:sub(prefixlen + 2):lower()
- -- Divide em palavras
- local words = {}
- for word in text:gmatch("%S+") do
- table.insert(words, word)
- end
- local cmd = words[1]
- local args = {}
- for i = 2, #words do
- table.insert(args, words[i])
- end
- -- Executa comando
- if cmd and commands[cmd] and type(commands[cmd].func) == "function" then
- commands[cmd].func(args)
- return true
- else
- utils.msgAlerta("Comando desconhecido ou inválido: " .. tostring(cmd), "&cZen")
- end
- end
- return false
- end
- -- Loop principal
- utils.centerXY("ZEN !IA")
- while true do
- local event, player, message = os.pullEvent("chat")
- handleCommand(message, player)
- end
Advertisement
Add Comment
Please, Sign In to add comment