commit
5aab51676c
93
README.md
93
README.md
|
@ -1,48 +1,45 @@
|
|||
# MultiChat v1.1.2
|
||||
|
||||
[![Baixar](https://img.shields.io/badge/Baixar-v1.1.2-green.svg)](https://github.com/BrunoMine/multichat/archive/v1.1.2.zip)
|
||||
[![Projeto](https://img.shields.io/badge/Git-Projeto-green.svg)](https://github.com/BrunoMine/multichat)
|
||||
[![!Bower](https://img.shields.io/badge/Bower-Projeto-green.svg)](https://minetest-bower.herokuapp.com/mods/multichat)
|
||||
[![Licença](https://img.shields.io/badge/Licença-LGPL_v3.0-blue.svg)](https://github.com/BrunoMine/multichat/blob/master/LICENSE)
|
||||
|
||||
## Descrição
|
||||
Adiciona funcionalidades ao bate-papo
|
||||
* Prefixos para administradores e moderadores
|
||||
* Grupo de bate-papo privado
|
||||
* Ignorar jogadores no bate-papo
|
||||
* Sons de bate-papo
|
||||
|
||||
## Requisitos _(Requirements)_
|
||||
|
||||
* Minetest 0.4.16 ou superior
|
||||
* Mod default
|
||||
* Mod manipulus (opicional)
|
||||
* Mod intllib (opicional)
|
||||
|
||||
## Comandos _(Commands)_
|
||||
|
||||
* `/chat` : Abre o painel de configuração do bate-papo
|
||||
|
||||
## Privilégios _(Privileges)_
|
||||
|
||||
* `chat_admin` : Adiciona prefixo de adminstrador (`[ADMIN]`, configurável) nas falas no bate-papo
|
||||
* `chat_staff` : Adiciona prefixo de moderador (`[MODERADOR]`, configurável) nas falas no bate-papo
|
||||
|
||||
## Licença
|
||||
Veja LICENSE.txt para informações detalhadas da licença LGPL 3.0
|
||||
|
||||
### Autores do código fonte
|
||||
Originalmente por BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (LGPL 3.0)
|
||||
|
||||
### Autores de mídias (texturas, modelos and sons)
|
||||
Todos que não estao listados aqui:
|
||||
BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)
|
||||
|
||||
Desconhecido (CC0)
|
||||
multichat_aviso.ogg
|
||||
|
||||
UnderlinedDesigns (CC0)
|
||||
multichat_chamada.ogg
|
||||
|
||||
|
||||
|
||||
# MultiChat v1.1.2
|
||||
|
||||
[![Baixar](https://img.shields.io/badge/Baixar-v1.1.2-green.svg)](https://github.com/BrunoMine/multichat/archive/v1.1.2.zip)
|
||||
[![Projeto](https://img.shields.io/badge/Git-Projeto-green.svg)](https://github.com/BrunoMine/multichat)
|
||||
[![!Bower](https://img.shields.io/badge/Bower-Projeto-green.svg)](https://minetest-bower.herokuapp.com/mods/multichat)
|
||||
[![Licença](https://img.shields.io/badge/Licença-LGPL_v3.0-blue.svg)](https://github.com/BrunoMine/multichat/blob/master/LICENSE)
|
||||
|
||||
## Descrição
|
||||
Adiciona funcionalidades ao bate-papo
|
||||
* Prefixos para administradores e moderadores
|
||||
* Grupo de bate-papo privado
|
||||
* Ignorar jogadores no bate-papo
|
||||
* Sons de bate-papo
|
||||
|
||||
## Requisitos _(Requirements)_
|
||||
|
||||
* Minetest 0.4.16 ou superior
|
||||
* Mod default
|
||||
* Mod manipulus (opicional)
|
||||
* Mod intllib (opicional)
|
||||
|
||||
## Comandos _(Commands)_
|
||||
|
||||
* `/chat` : Abre o painel de configuração do bate-papo
|
||||
|
||||
## Privilégios _(Privileges)_
|
||||
|
||||
* `chat_admin` : Adiciona prefixo de adminstrador (`[ADMIN]`, configurável) nas falas no bate-papo
|
||||
* `chat_staff` : Adiciona prefixo de moderador (`[MODERADOR]`, configurável) nas falas no bate-papo
|
||||
|
||||
## Licença
|
||||
Veja LICENSE.txt para informações detalhadas da licença LGPL 3.0
|
||||
|
||||
### Autores do código fonte
|
||||
Originalmente por BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (LGPL 3.0)
|
||||
|
||||
### Autores de mídias (texturas, modelos and sons)
|
||||
Todos que não estao listados aqui:
|
||||
BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)
|
||||
|
||||
Desconhecido (CC0)
|
||||
multichat_aviso.ogg
|
||||
|
||||
UnderlinedDesigns (CC0)
|
||||
multichat_chamada.ogg
|
||||
|
|
349
chat.lua
349
chat.lua
|
@ -1,174 +1,175 @@
|
|||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Chat
|
||||
|
||||
]]
|
||||
|
||||
local S = multichat.S
|
||||
|
||||
minetest.register_privilege("chat_admin", S("Usar chat como administrador"))
|
||||
minetest.register_privilege("chat_staff", S("Usar chat como moderador"))
|
||||
|
||||
-- Grupos privados de cada jogador
|
||||
multichat.grupos = {}
|
||||
|
||||
-- Pegar prefixos
|
||||
S = multichat.Sfake
|
||||
multichat.admin_prefix = minetest.setting_get("multichat_admin_prefix") or S("ADMIN")
|
||||
multichat.staff_prefix = minetest.setting_get("multichat_staff_prefix") or S("MODERADOR")
|
||||
S = multichat.S
|
||||
|
||||
local tocar_som = function(player) minetest.sound_play("multichat_aviso", {object = player,gain = 0.5,max_hear_distance = 1}) end
|
||||
local tocar_chamada = function(player) minetest.sound_play("multichat_chamada", {object = player,gain = 0.5,max_hear_distance = 1}) end
|
||||
-- Emitir som de aviso
|
||||
multichat.som_avisar = function(name, msg)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
||||
-- Verificar se vai ser som de chamada
|
||||
if msg
|
||||
and player:get_attribute("multichat_chamada") ~= "false"
|
||||
and string.find(msg, name) ~= nil
|
||||
then
|
||||
tocar_chamada(player)
|
||||
-- Verifica se vai ser som normal
|
||||
elseif player:get_attribute("multichat_som") ~= "false" then
|
||||
tocar_som(player)
|
||||
end
|
||||
|
||||
end
|
||||
local som_avisar = multichat.som_avisar
|
||||
|
||||
-- Pegar prefixo
|
||||
multichat.prefixo = function(name)
|
||||
if minetest.check_player_privs(name, {chat_admin=true}) then return "["..S(multichat.admin_prefix).."]" end
|
||||
if minetest.check_player_privs(name, {chat_staff=true}) then return "["..S(multichat.staff_prefix).."]" end
|
||||
return ""
|
||||
end
|
||||
|
||||
-- Enviar mensagem para jogador
|
||||
local enviar_msg = function(name, msg, falante)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(falante)..falante.."> "..msg)
|
||||
|
||||
-- Evita avisar a si mesmo
|
||||
if name ~= falante then
|
||||
som_avisar(name, msg)
|
||||
else
|
||||
som_avisar(name)
|
||||
end
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
return
|
||||
|
||||
-- Verifica se o jogador está ouvindo apenas seu grupo de guilda
|
||||
elseif status == "guilda" then
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(falante)..falante.."> "..msg)
|
||||
|
||||
-- Evita avisar a si mesmo
|
||||
if name ~= falante then
|
||||
som_avisar(name, msg)
|
||||
else
|
||||
som_avisar(name)
|
||||
end
|
||||
|
||||
-- Verifica se jogador está ouvindo apenas seu grupo privado
|
||||
elseif status == "grupo" and multichat.grupos[name] then
|
||||
|
||||
-- Verifica se falante está no grupo
|
||||
if multichat.grupos[name][falante] then
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(falante)..falante.."> "..msg)
|
||||
som_avisar(name, msg)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Chamada para envio de mensagens de jogadores
|
||||
minetest.register_on_chat_message(function(name, msg)
|
||||
-- Verifica se tem privilegio para falar
|
||||
if minetest.check_player_privs(name, {shout=true}) ~= true then return true end
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
|
||||
-- Envia a mensagem para todos os jogadores
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
enviar_msg(player:get_player_name(), msg, name)
|
||||
end
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
minetest.chat_send_player(name, "Bate-papo desativado")
|
||||
|
||||
-- Verifica se jogador está falando apenas com seu grupo
|
||||
elseif status == "guilda" then
|
||||
|
||||
-- Verifica se o recurso esta ativo
|
||||
if multichat.guild == false then return true end
|
||||
|
||||
-- Mod manipulus
|
||||
if multichat.mod_guild == "manipulus" then
|
||||
-- Guilda do ouvinte
|
||||
local mg = manipulus.get_player_grupo(name)
|
||||
-- Verifica se guilda ainda existe
|
||||
if mg == nil or manipulus.existe_grupo(mg) == false then return true end
|
||||
-- Envia a mensagem para todos os jogadores
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local n = player:get_player_name()
|
||||
if manipulus.get_player_grupo(n) == mg then
|
||||
enviar_msg(n, msg, name)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Verifica se jogador está falando apenas com seu grupo privado
|
||||
elseif status == "grupo" then
|
||||
|
||||
-- Envia a mensagem para todos os jogadores do grupo
|
||||
for np,v in pairs(multichat.grupos[name] or {}) do
|
||||
enviar_msg(np, msg, name)
|
||||
end
|
||||
|
||||
-- Envia a si mesmo tambem para aparecer no console
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(name)..name.."> "..msg)
|
||||
som_avisar(name)
|
||||
end
|
||||
return true
|
||||
end)
|
||||
|
||||
|
||||
-- Verificador de jogadores offline para remover grupos
|
||||
local timer = 0
|
||||
local tlim = tonumber(minetest.setting_get("multichat_tempo_verif_grupo") or 3600)
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime;
|
||||
if timer >= 3600 then
|
||||
-- Mantar apenas grupos de jogadores online
|
||||
local onlines = {}
|
||||
-- Mudar tabela
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
onlines[player:get_player_name()] = true
|
||||
end
|
||||
for name,i in pairs(multichat.grupos) do
|
||||
if not onlines[name] then
|
||||
multichat.grupos[name] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Chat
|
||||
|
||||
]]
|
||||
|
||||
local S = multichat.S
|
||||
|
||||
minetest.register_privilege("chat_admin", S("Usar chat como administrador"))
|
||||
minetest.register_privilege("chat_staff", S("Usar chat como moderador"))
|
||||
|
||||
-- Grupos privados de cada jogador
|
||||
multichat.grupos = {}
|
||||
|
||||
-- Pegar prefixos
|
||||
S = multichat.Sfake
|
||||
multichat.admin_prefix = minetest.setting_get("multichat_admin_prefix") or S("ADMIN")
|
||||
multichat.staff_prefix = minetest.setting_get("multichat_staff_prefix") or S("MODERADOR")
|
||||
S = multichat.S
|
||||
|
||||
local tocar_som = function(player) minetest.sound_play("multichat_aviso", {object = player,gain = 0.5,max_hear_distance = 1}) end
|
||||
local tocar_chamada = function(player) minetest.sound_play("multichat_chamada", {object = player,gain = 0.5,max_hear_distance = 1}) end
|
||||
-- Emitir som de aviso
|
||||
multichat.som_avisar = function(name, msg)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
||||
-- Verificar se vai ser som de chamada
|
||||
if msg
|
||||
and player:get_attribute("multichat_chamada") ~= "false"
|
||||
and string.find(msg, name) ~= nil
|
||||
then
|
||||
tocar_chamada(player)
|
||||
-- Verifica se vai ser som normal
|
||||
elseif player:get_attribute("multichat_som") ~= "false" then
|
||||
tocar_som(player)
|
||||
end
|
||||
|
||||
end
|
||||
local som_avisar = multichat.som_avisar
|
||||
|
||||
-- Pegar prefixo
|
||||
multichat.prefixo = function(name)
|
||||
if minetest.check_player_privs(name, {chat_admin=true}) then return "["..S(multichat.admin_prefix).."]" end
|
||||
if minetest.check_player_privs(name, {chat_staff=true}) then return "["..S(multichat.staff_prefix).."]" end
|
||||
return ""
|
||||
end
|
||||
|
||||
-- Enviar mensagem para jogador
|
||||
local enviar_msg = function(name, msg, falante)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(falante)..falante.."> "..msg)
|
||||
|
||||
-- Evita avisar a si mesmo
|
||||
if name ~= falante then
|
||||
som_avisar(name, msg)
|
||||
else
|
||||
som_avisar(name)
|
||||
end
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
return
|
||||
|
||||
-- Verifica se o jogador está ouvindo apenas seu grupo de guilda
|
||||
elseif status == "guilda" then
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(falante)..falante.."> "..msg)
|
||||
|
||||
-- Evita avisar a si mesmo
|
||||
if name ~= falante then
|
||||
som_avisar(name, msg)
|
||||
else
|
||||
som_avisar(name)
|
||||
end
|
||||
|
||||
-- Verifica se jogador está ouvindo apenas seu grupo privado
|
||||
elseif status == "grupo" and multichat.grupos[name] then
|
||||
|
||||
-- Verifica se falante está no grupo
|
||||
if multichat.grupos[name][falante] then
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(falante)..falante.."> "..msg)
|
||||
som_avisar(name, msg)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Chamada para envio de mensagens de jogadores
|
||||
local function on_chat_message(name, msg)
|
||||
-- Verifica se tem privilegio para falar
|
||||
if msg:sub(1, 1) == "/" or not minetest.get_player_by_name(name) then
|
||||
return
|
||||
end
|
||||
if not minetest.check_player_privs(name, {shout=true}) then return true end
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
|
||||
-- Envia a mensagem para todos os jogadores
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
enviar_msg(player:get_player_name(), msg, name)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("irc") then
|
||||
irc.say("<" .. name.. "> " .. msg)
|
||||
end
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
minetest.chat_send_player(name, "Bate-papo desativado")
|
||||
|
||||
-- Verifica se jogador está falando apenas com seu grupo
|
||||
elseif status == "guilda" then
|
||||
|
||||
-- Verifica se o recurso esta ativo
|
||||
if not multichat.guild then return true end
|
||||
|
||||
-- Mod manipulus
|
||||
if multichat.mod_guild == "manipulus" then
|
||||
-- Guilda do ouvinte
|
||||
local mg = manipulus.get_player_grupo(name)
|
||||
-- Verifica se guilda ainda existe
|
||||
if mg == nil or not manipulus.existe_grupo(mg) then return true end
|
||||
-- Envia a mensagem para todos os jogadores
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local n = player:get_player_name()
|
||||
if manipulus.get_player_grupo(n) == mg then
|
||||
enviar_msg(n, msg, name)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Verifica se jogador está falando apenas com seu grupo privado
|
||||
elseif status == "grupo" then
|
||||
|
||||
-- Envia a mensagem para todos os jogadores do grupo
|
||||
for np,v in pairs(multichat.grupos[name] or {}) do
|
||||
enviar_msg(np, msg, name)
|
||||
end
|
||||
|
||||
-- Envia a si mesmo tambem para aparecer no console
|
||||
minetest.chat_send_player(name, "<"..multichat.prefixo(name)..name.."> "..msg)
|
||||
som_avisar(name)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if minetest.get_modpath("irc") then
|
||||
table.insert(minetest.registered_on_chat_messages, 2, on_chat_message)
|
||||
minetest.callback_origins[on_chat_message] = {
|
||||
mod = "multichat",
|
||||
name = "on_chat_message"
|
||||
}
|
||||
else
|
||||
minetest.register_on_chat_message(on_chat_message)
|
||||
end
|
||||
|
||||
-- Verificador de jogadores offline para remover grupos
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
multichat.grupos[player:get_player_name()] = nil
|
||||
end)
|
||||
|
|
42
comandos.lua
42
comandos.lua
|
@ -1,21 +1,21 @@
|
|||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Comandos
|
||||
|
||||
]]
|
||||
|
||||
local S = multichat.S
|
||||
|
||||
minetest.register_chatcommand("chat", {
|
||||
description = S("Abrir painel do bate-papo"),
|
||||
privs = {},
|
||||
func = function(name)
|
||||
multichat.acessar_menu(name)
|
||||
end,
|
||||
})
|
||||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Comandos
|
||||
|
||||
]]
|
||||
|
||||
local S = multichat.S
|
||||
|
||||
minetest.register_chatcommand("chat", {
|
||||
description = S("Abrir painel do bate-papo"),
|
||||
privs = {},
|
||||
func = function(name)
|
||||
multichat.acessar_menu(name)
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
default
|
||||
irc?
|
||||
sfinv?
|
||||
mymenu?
|
||||
manipulus?
|
||||
sfinv_menu?
|
||||
unified_inventory?
|
||||
|
|
94
init.lua
94
init.lua
|
@ -1,47 +1,47 @@
|
|||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
]]
|
||||
|
||||
|
||||
-- Variavel global
|
||||
multichat = {}
|
||||
|
||||
-- Notificador de Inicializador
|
||||
local notificar = function(msg)
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.debug("[MULTICHAT]"..msg)
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar compatibilidades de versão
|
||||
-- Versão do servidor
|
||||
if minetest.get_version().string and string.find(minetest.get_version().string, "0.4.15") then
|
||||
minetest.log("error", "[MULTICHAT] Versao imcompativel (use 0.4.16 ou superior)")
|
||||
end
|
||||
|
||||
-- Verifica se tem mod de grupo/guilda
|
||||
multichat.guild = false
|
||||
if minetest.get_modpath("manipulus") then
|
||||
multichat.guild = true
|
||||
multichat.mod_guild = "manipulus"
|
||||
end
|
||||
|
||||
-- Modpath
|
||||
local modpath = minetest.get_modpath("multichat")
|
||||
|
||||
-- Carregar scripts
|
||||
notificar("Carregando...")
|
||||
dofile(modpath.."/tradutor.lua")
|
||||
dofile(modpath.."/online.lua")
|
||||
dofile(modpath.."/chat.lua")
|
||||
dofile(modpath.."/menu.lua")
|
||||
dofile(modpath.."/msg.lua")
|
||||
dofile(modpath.."/me.lua")
|
||||
dofile(modpath.."/comandos.lua")
|
||||
notificar("OK!")
|
||||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
]]
|
||||
|
||||
|
||||
-- Variavel global
|
||||
multichat = {}
|
||||
|
||||
-- Notificador de Inicializador
|
||||
local notificar = function(msg)
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.debug("[MULTICHAT]"..msg)
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar compatibilidades de versão
|
||||
-- Versão do servidor
|
||||
if minetest.get_version().string and string.find(minetest.get_version().string, "0.4.15") then
|
||||
minetest.log("error", "[MULTICHAT] Versao imcompativel (use 0.4.16 ou superior)")
|
||||
end
|
||||
|
||||
-- Verifica se tem mod de grupo/guilda
|
||||
multichat.guild = false
|
||||
if minetest.get_modpath("manipulus") then
|
||||
multichat.guild = true
|
||||
multichat.mod_guild = "manipulus"
|
||||
end
|
||||
|
||||
-- Modpath
|
||||
local modpath = minetest.get_modpath("multichat")
|
||||
|
||||
-- Carregar scripts
|
||||
notificar("Carregando...")
|
||||
dofile(modpath.."/tradutor.lua")
|
||||
dofile(modpath.."/online.lua")
|
||||
dofile(modpath.."/chat.lua")
|
||||
dofile(modpath.."/menu.lua")
|
||||
dofile(modpath.."/msg.lua")
|
||||
dofile(modpath.."/me.lua")
|
||||
dofile(modpath.."/comandos.lua")
|
||||
notificar("OK!")
|
||||
|
|
158
me.lua
158
me.lua
|
@ -1,79 +1,79 @@
|
|||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ajuste no comando /msg
|
||||
|
||||
]]
|
||||
|
||||
|
||||
local som_avisar = multichat.som_avisar
|
||||
|
||||
-- Enviar mensagem para jogador
|
||||
local enviar_msg = function(name, msg, falante)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
minetest.chat_send_player(name, "* "..falante.." "..msg)
|
||||
|
||||
-- Evita avisar a si mesmo
|
||||
if name ~= falante then
|
||||
som_avisar(name, msg)
|
||||
else
|
||||
som_avisar(name)
|
||||
end
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
return
|
||||
|
||||
-- Verifica se está em grupo da guilda
|
||||
elseif status == "guilda" then
|
||||
|
||||
-- Verifica se o recurso esta ativo
|
||||
if multichat.guild == false then return end
|
||||
|
||||
-- Mod manipulus
|
||||
if multichat.mod_guild == "manipulus" then
|
||||
-- Guilda do ouvinte
|
||||
local my_guild = manipulus.get_player_grupo(name)
|
||||
-- Verifica se guilda ainda existe
|
||||
if my_guild == nil or manipulus.existe_grupo(my_guild) == false then return end
|
||||
-- Guilda do falante
|
||||
local you_guild = manipulus.get_player_grupo(falante)
|
||||
-- Verifica se guilda ainda existe
|
||||
if you_guild == nil or manipulus.existe_grupo(you_guild) == false then return end
|
||||
-- Envia mensagem
|
||||
minetest.chat_send_player(name, "* "..falante.." "..msg)
|
||||
som_avisar(name, msg)
|
||||
end
|
||||
|
||||
-- Verifica se jogador está ouvindo apenas seu grupo
|
||||
elseif status == "grupo" and multichat.grupos[name] then
|
||||
|
||||
-- Verifica se falante está no grupo
|
||||
if multichat.grupos[name][falante] then
|
||||
minetest.chat_send_player(name, "* "..falante.." "..msg)
|
||||
som_avisar(name, msg)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local old_func = minetest.chatcommands.me.func
|
||||
|
||||
function minetest.chatcommands.me.func(name, param)
|
||||
|
||||
-- Enviar chamada em todos os jogadores
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local np = player:get_player_name()
|
||||
enviar_msg(np, param, name)
|
||||
end
|
||||
|
||||
end
|
||||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ajuste no comando /msg
|
||||
|
||||
]]
|
||||
|
||||
|
||||
local som_avisar = multichat.som_avisar
|
||||
|
||||
-- Enviar mensagem para jogador
|
||||
local enviar_msg = function(name, msg, falante)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
minetest.chat_send_player(name, "* "..falante.." "..msg)
|
||||
|
||||
-- Evita avisar a si mesmo
|
||||
if name ~= falante then
|
||||
som_avisar(name, msg)
|
||||
else
|
||||
som_avisar(name)
|
||||
end
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
return
|
||||
|
||||
-- Verifica se está em grupo da guilda
|
||||
elseif status == "guilda" then
|
||||
|
||||
-- Verifica se o recurso esta ativo
|
||||
if multichat.guild == false then return end
|
||||
|
||||
-- Mod manipulus
|
||||
if multichat.mod_guild == "manipulus" then
|
||||
-- Guilda do ouvinte
|
||||
local my_guild = manipulus.get_player_grupo(name)
|
||||
-- Verifica se guilda ainda existe
|
||||
if my_guild == nil or manipulus.existe_grupo(my_guild) == false then return end
|
||||
-- Guilda do falante
|
||||
local you_guild = manipulus.get_player_grupo(falante)
|
||||
-- Verifica se guilda ainda existe
|
||||
if you_guild == nil or manipulus.existe_grupo(you_guild) == false then return end
|
||||
-- Envia mensagem
|
||||
minetest.chat_send_player(name, "* "..falante.." "..msg)
|
||||
som_avisar(name, msg)
|
||||
end
|
||||
|
||||
-- Verifica se jogador está ouvindo apenas seu grupo
|
||||
elseif status == "grupo" and multichat.grupos[name] then
|
||||
|
||||
-- Verifica se falante está no grupo
|
||||
if multichat.grupos[name][falante] then
|
||||
minetest.chat_send_player(name, "* "..falante.." "..msg)
|
||||
som_avisar(name, msg)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local old_func = minetest.chatcommands.me.func
|
||||
|
||||
function minetest.chatcommands.me.func(name, param)
|
||||
|
||||
-- Enviar chamada em todos os jogadores
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local np = player:get_player_name()
|
||||
enviar_msg(np, param, name)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
555
menu.lua
555
menu.lua
|
@ -1,270 +1,285 @@
|
|||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Menu Multichat
|
||||
|
||||
]]
|
||||
|
||||
local S = multichat.S
|
||||
|
||||
-- Remover grupo de um jogador offline
|
||||
local remover_grupo = function(name)
|
||||
multichat.salas[name] = nil
|
||||
end
|
||||
|
||||
-- Comando de acesso ao menu
|
||||
multichat.acessar_menu = function(name)
|
||||
if not name then return end
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local st = player:get_attribute("multichat_status")
|
||||
|
||||
local status = S("Atualmente").."\n"
|
||||
|
||||
-- Caso esteja no Publico
|
||||
if st == nil or st == "pub" then
|
||||
status = status .. minetest.colorize("#00FF00", S("em Publico"))
|
||||
|
||||
-- Caso esteja Desativado
|
||||
elseif st == "off" then
|
||||
status = status .. minetest.colorize("#FF0000", S("Desativado"))
|
||||
|
||||
-- Caso esteja no Grupo Privado
|
||||
elseif st == "grupo" then
|
||||
status = status .. minetest.colorize("#3366FF", S("em Privado"))
|
||||
|
||||
-- Caso esteja no Grupo da Guilda
|
||||
elseif st == "guilda" then
|
||||
status = status .. minetest.colorize("#3366FF", S("em Grupo"))
|
||||
|
||||
-- Caso nenhuma situação prevista
|
||||
else
|
||||
status = status .. S("Erro")
|
||||
end
|
||||
|
||||
-- Avisos sonoros
|
||||
local st_som = player:get_attribute("multichat_som") or "true"
|
||||
local st_chamada = player:get_attribute("multichat_chamada") or "true"
|
||||
|
||||
local formspec = ""
|
||||
if multichat.guild == true then
|
||||
formspec = formspec .. "size[4,6]"
|
||||
else
|
||||
formspec = formspec .. "size[4,5]"
|
||||
end
|
||||
|
||||
formspec = formspec
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."label[0,0;"..S("Meu Bate-Papo").."\n"..status.."]"
|
||||
.."image[3,0;1,1;multichat_botao.png]"
|
||||
.."checkbox[0,1;som;"..S("Som")..";"..st_som.."]"
|
||||
.."checkbox[0,1.5;chamada;"..S("Chamada")..";"..st_chamada.."]"
|
||||
.."button_exit[3,1.2;1,1;sair;"..S("Sair").."]"
|
||||
.."button_exit[0,2.2;4,1;desativar;"..S("Desativar").."]"
|
||||
.."button_exit[0,3.2;4,1;publico;"..S("Publico").."]"
|
||||
.."button_exit[0,4.2;3.3,1;privado;"..S("Privado").."]"
|
||||
.."image_button[3.15,4.3;0.825,0.825;default_book_written.png;grupo;]"
|
||||
|
||||
-- Botão de grupo
|
||||
if multichat.guild == true then
|
||||
formspec = formspec .. "button_exit[0,5.2;4,1;guild;"..S("Grupo").."]"
|
||||
end
|
||||
minetest.show_formspec(name, "multichat:menu", formspec)
|
||||
end
|
||||
|
||||
-- Acessar menu do grupo
|
||||
local acessar_menu_grupo = function(name)
|
||||
|
||||
-- Prepara e armazena tabelas exibidas
|
||||
local tb_grupo = multichat.grupos[name] or {}
|
||||
multichat.online[name].tb_grupo = {}
|
||||
local st_grupo = ""
|
||||
for np,v in pairs(tb_grupo) do
|
||||
if st_grupo ~= "" then st_grupo = st_grupo .. "," end
|
||||
st_grupo = st_grupo .. np
|
||||
table.insert(multichat.online[name].tb_grupo, np)
|
||||
end
|
||||
|
||||
local tb_online = minetest.get_connected_players()
|
||||
multichat.online[name].tb_online = {}
|
||||
local st_online = ""
|
||||
local i = 1
|
||||
while i <= table.maxn(tb_online) do
|
||||
local np = tb_online[i]:get_player_name()
|
||||
|
||||
-- Remove o proprio nome da lista
|
||||
if np == name then
|
||||
table.remove(tb_online, i)
|
||||
-- Remove nomes que estao no grupo
|
||||
elseif tb_grupo[np] then
|
||||
table.remove(tb_online, i)
|
||||
-- Insere na lista
|
||||
else
|
||||
if st_online ~= "" then st_online = st_online .. "," end
|
||||
st_online = st_online .. np
|
||||
table.insert(multichat.online[name].tb_online, np)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
end
|
||||
minetest.show_formspec(name, "multichat:menu_grupo", "size[8,6]"
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."label[0,0;"..S("Meu Bate-Papo Privado").."]"
|
||||
.."button[6.1,-0.1;2,1;voltar;"..S("Voltar").."]"
|
||||
|
||||
.."label[0,1.1;"..S("Ignorados").."]"
|
||||
.."textlist[0,1.6;3,4.5;online;"..st_online.."]"
|
||||
|
||||
.."image[3.5,1.7;1,1;gui_furnace_arrow_bg.png^[transformR270]"
|
||||
.."button[3.1,2.5;1.9,1;adicionar;"..S("Adicionar").."]"
|
||||
|
||||
.."button[3.1,4.3;1.9,1;remover;"..S("Remover").."]"
|
||||
.."image[3.5,5;1,1;gui_furnace_arrow_bg.png^[transformR90]"
|
||||
|
||||
.."label[4.85,1.1;"..S("Conversando").."]"
|
||||
.."textlist[4.85,1.6;3,4.5;grupo;"..st_grupo.."]"
|
||||
)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname == "multichat:menu" then
|
||||
|
||||
-- Botao de desativar bate-papo
|
||||
if fields.desativar then
|
||||
player:set_attribute("multichat_status", "off")
|
||||
minetest.chat_send_player(player:get_player_name(), S("Bate-papo desativado"))
|
||||
|
||||
elseif fields.publico then
|
||||
player:set_attribute("multichat_status", "pub")
|
||||
minetest.chat_send_player(player:get_player_name(), S("Foste para o bate-papo publico"))
|
||||
|
||||
elseif fields.privado then
|
||||
player:set_attribute("multichat_status", "grupo")
|
||||
minetest.chat_send_player(player:get_player_name(), S("Foste para o bate-papo privado"))
|
||||
|
||||
elseif fields.grupo then
|
||||
acessar_menu_grupo(player:get_player_name())
|
||||
|
||||
-- Guilda
|
||||
elseif fields.guild then
|
||||
-- Manipulus
|
||||
if multichat.mod_guild == "manipulus" then
|
||||
local grupo = manipulus.get_player_grupo(player:get_player_name())
|
||||
if grupo == nil or manipulus.existe_grupo(grupo) == false then
|
||||
minetest.chat_send_player(player:get_player_name(), S("Precisa entrar em um grupo"))
|
||||
else
|
||||
player:set_attribute("multichat_status", "guilda")
|
||||
minetest.chat_send_player(player:get_player_name(), S("Foste para o bate-papo do grupo @1", "'"..grupo.."'"))
|
||||
end
|
||||
end
|
||||
|
||||
-- Caixas de seleção (avisos sonoros)
|
||||
elseif fields.som then
|
||||
player:set_attribute("multichat_som", fields.som)
|
||||
elseif fields.chamada then
|
||||
player:set_attribute("multichat_chamada", fields.chamada)
|
||||
|
||||
end
|
||||
|
||||
elseif formname == "multichat:menu_grupo" then
|
||||
|
||||
-- Limpa variaveis quando sair (evitar o uso delas no futuro)
|
||||
if fields.quit then
|
||||
multichat.online[player:get_player_name()].sl_tb_online = nil
|
||||
multichat.online[player:get_player_name()].sl_tb_grupo = nil
|
||||
-- Verifica seleções
|
||||
elseif fields.online then
|
||||
multichat.online[player:get_player_name()].sl_tb_online = string.split(fields.online, ":")[2]
|
||||
elseif fields.grupo then
|
||||
multichat.online[player:get_player_name()].sl_tb_grupo = string.split(fields.grupo, ":")[2]
|
||||
|
||||
-- Voltar ao menu principal
|
||||
elseif fields.voltar then
|
||||
multichat.acessar_menu(player:get_player_name())
|
||||
return
|
||||
|
||||
-- Adicionar jogador para conversar
|
||||
elseif fields.adicionar then
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verifica se tem algum jogador na tabela
|
||||
if table.maxn(multichat.online[name].tb_online) == 0 then return end
|
||||
|
||||
-- Verifica se selecionou umjogador
|
||||
if not tonumber(multichat.online[name].sl_tb_online) then return end
|
||||
|
||||
-- Caso o grupo esteja vazio cria
|
||||
if multichat.grupos[name] == nil then multichat.grupos[name] = {} end
|
||||
|
||||
-- Adiciona jogador
|
||||
local sl = tonumber(multichat.online[name].sl_tb_online)
|
||||
local grupo = multichat.online[name].tb_online[sl]
|
||||
multichat.grupos[name][grupo] = true
|
||||
|
||||
-- Atualiza menu do grupo
|
||||
acessar_menu_grupo(name)
|
||||
|
||||
return
|
||||
|
||||
-- Remover jogador
|
||||
elseif fields.remover then
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verifica se tem algum jogador na tabela
|
||||
if table.maxn(multichat.online[name].tb_grupo) == 0 then return end
|
||||
|
||||
-- Verifica se selecionou umjogador
|
||||
if not tonumber(multichat.online[name].sl_tb_grupo) then return end
|
||||
|
||||
-- Remove jogador do grupo
|
||||
local sl = tonumber(multichat.online[name].sl_tb_grupo)
|
||||
if multichat.grupos[name] ~= nil
|
||||
and multichat.online[name].tb_grupo ~= nil
|
||||
and multichat.online[name].tb_grupo[sl] ~= nil
|
||||
then
|
||||
multichat.grupos[name][multichat.online[name].tb_grupo[sl]] = nil
|
||||
end
|
||||
|
||||
-- Atualiza menu do grupo
|
||||
acessar_menu_grupo(name)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
-- Registrar em 'sfinv'
|
||||
if mymenu then
|
||||
|
||||
-- Registrar metodo de tradução instantanea
|
||||
mymenu.register_tr(SS)
|
||||
|
||||
-- Registrar botao
|
||||
mymenu.register_button("multichat:abrir_menu", S("Bate-Papo"))
|
||||
|
||||
-- Receber botao do inventario
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields["multichat:abrir_menu"] then
|
||||
multichat.acessar_menu(player:get_player_name())
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
if sfinv_menu then
|
||||
sfinv_menu.register_button("multichat:menu", {
|
||||
title = S("Bate-Papo"),
|
||||
icon = "multichat_botao.png",
|
||||
func = function(player)
|
||||
multichat.acessar_menu(player:get_player_name())
|
||||
end,
|
||||
})
|
||||
end
|
||||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Menu Multichat
|
||||
|
||||
]]
|
||||
|
||||
local S = multichat.S
|
||||
|
||||
-- Remover grupo de um jogador offline
|
||||
local remover_grupo = function(name)
|
||||
multichat.salas[name] = nil
|
||||
end
|
||||
|
||||
-- Comando de acesso ao menu
|
||||
multichat.acessar_menu = function(name)
|
||||
if not name then return end
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local st = player:get_attribute("multichat_status")
|
||||
|
||||
local status = S("Atualmente").."\n"
|
||||
|
||||
-- Caso esteja no Publico
|
||||
if st == nil or st == "pub" then
|
||||
status = status .. minetest.colorize("#00FF00", S("em Publico"))
|
||||
|
||||
-- Caso esteja Desativado
|
||||
elseif st == "off" then
|
||||
status = status .. minetest.colorize("#FF0000", S("Desativado"))
|
||||
|
||||
-- Caso esteja no Grupo Privado
|
||||
elseif st == "grupo" then
|
||||
status = status .. minetest.colorize("#3366FF", S("em Privado"))
|
||||
|
||||
-- Caso esteja no Grupo da Guilda
|
||||
elseif st == "guilda" then
|
||||
status = status .. minetest.colorize("#3366FF", S("em Grupo"))
|
||||
|
||||
-- Caso nenhuma situação prevista
|
||||
else
|
||||
status = status .. S("Erro")
|
||||
end
|
||||
|
||||
-- Avisos sonoros
|
||||
local st_som = player:get_attribute("multichat_som") or "true"
|
||||
local st_chamada = player:get_attribute("multichat_chamada") or "true"
|
||||
|
||||
local formspec = ""
|
||||
if multichat.guild == true then
|
||||
formspec = formspec .. "size[4,6]"
|
||||
else
|
||||
formspec = formspec .. "size[4,5]"
|
||||
end
|
||||
|
||||
formspec = formspec
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."label[0,0;"..S("Meu Bate-Papo").."\n"..status.."]"
|
||||
.."image[3,0;1,1;multichat_botao.png]"
|
||||
.."checkbox[0,1;som;"..S("Som")..";"..st_som.."]"
|
||||
.."checkbox[0,1.5;chamada;"..S("Chamada")..";"..st_chamada.."]"
|
||||
.."button_exit[3,1.2;1,1;sair;"..S("Sair").."]"
|
||||
.."button[0,2.2;4,1;desativar;"..S("Desativar").."]"
|
||||
.."button[0,3.2;4,1;publico;"..S("Publico").."]"
|
||||
.."button[0,4.2;3.3,1;privado;"..S("Privado").."]"
|
||||
.."image_button[3.15,4.3;0.825,0.825;default_book_written.png;grupo;]"
|
||||
|
||||
-- Botão de grupo
|
||||
if multichat.guild == true then
|
||||
formspec = formspec .. "button_exit[0,5.2;4,1;guild;"..S("Grupo").."]"
|
||||
end
|
||||
minetest.show_formspec(name, "multichat:menu", formspec)
|
||||
end
|
||||
|
||||
-- Acessar menu do grupo
|
||||
local acessar_menu_grupo = function(name)
|
||||
|
||||
-- Prepara e armazena tabelas exibidas
|
||||
local tb_grupo = multichat.grupos[name] or {}
|
||||
multichat.online[name].tb_grupo = {}
|
||||
local st_grupo = ""
|
||||
for np,v in pairs(tb_grupo) do
|
||||
if st_grupo ~= "" then st_grupo = st_grupo .. "," end
|
||||
st_grupo = st_grupo .. np
|
||||
table.insert(multichat.online[name].tb_grupo, np)
|
||||
end
|
||||
|
||||
local tb_online = minetest.get_connected_players()
|
||||
multichat.online[name].tb_online = {}
|
||||
local st_online = ""
|
||||
local i = 1
|
||||
while i <= table.maxn(tb_online) do
|
||||
local np = tb_online[i]:get_player_name()
|
||||
|
||||
-- Remove o proprio nome da lista
|
||||
if np == name then
|
||||
table.remove(tb_online, i)
|
||||
-- Remove nomes que estao no grupo
|
||||
elseif tb_grupo[np] then
|
||||
table.remove(tb_online, i)
|
||||
-- Insere na lista
|
||||
else
|
||||
if st_online ~= "" then st_online = st_online .. "," end
|
||||
st_online = st_online .. np
|
||||
table.insert(multichat.online[name].tb_online, np)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
end
|
||||
minetest.show_formspec(name, "multichat:menu_grupo", "size[8,6]"
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."label[0,0;"..S("Meu Bate-Papo Privado").."]"
|
||||
.."button[6.1,-0.1;2,1;voltar;"..S("Voltar").."]"
|
||||
|
||||
.."label[0,1.1;"..S("Ignorados").."]"
|
||||
.."textlist[0,1.6;3,4.5;online;"..st_online.."]"
|
||||
|
||||
.."image[3.5,1.7;1,1;gui_furnace_arrow_bg.png^[transformR270]"
|
||||
.."button[3.1,2.5;1.9,1;adicionar;"..S("Adicionar").."]"
|
||||
|
||||
.."button[3.1,4.3;1.9,1;remover;"..S("Remover").."]"
|
||||
.."image[3.5,5;1,1;gui_furnace_arrow_bg.png^[transformR90]"
|
||||
|
||||
.."label[4.85,1.1;"..S("Conversando").."]"
|
||||
.."textlist[4.85,1.6;3,4.5;grupo;"..st_grupo.."]"
|
||||
)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname == "multichat:menu" then
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Botao de desativar bate-papo
|
||||
if fields.desativar then
|
||||
player:set_attribute("multichat_status", "off")
|
||||
minetest.chat_send_player(name, S("Bate-papo desativado"))
|
||||
multichat.acessar_menu(name)
|
||||
|
||||
elseif fields.publico then
|
||||
player:set_attribute("multichat_status", "pub")
|
||||
minetest.chat_send_player(name, S("Foste para o bate-papo publico"))
|
||||
multichat.acessar_menu(name)
|
||||
|
||||
elseif fields.privado then
|
||||
player:set_attribute("multichat_status", "grupo")
|
||||
minetest.chat_send_player(player:get_player_name(), S("Foste para o bate-papo privado"))
|
||||
multichat.acessar_menu(name)
|
||||
|
||||
elseif fields.grupo then
|
||||
acessar_menu_grupo(name)
|
||||
|
||||
-- Guilda
|
||||
elseif fields.guild then
|
||||
-- Manipulus
|
||||
if multichat.mod_guild == "manipulus" then
|
||||
local grupo = manipulus.get_player_grupo(name)
|
||||
if grupo == nil or manipulus.existe_grupo(grupo) == false then
|
||||
minetest.chat_send_player(name, S("Precisa entrar em um grupo"))
|
||||
else
|
||||
player:set_attribute("multichat_status", "guilda")
|
||||
minetest.chat_send_player(name, S("Foste para o bate-papo do grupo @1", "'"..grupo.."'"))
|
||||
end
|
||||
end
|
||||
|
||||
-- Caixas de seleção (avisos sonoros)
|
||||
elseif fields.som then
|
||||
player:set_attribute("multichat_som", fields.som)
|
||||
elseif fields.chamada then
|
||||
player:set_attribute("multichat_chamada", fields.chamada)
|
||||
|
||||
end
|
||||
|
||||
elseif formname == "multichat:menu_grupo" then
|
||||
|
||||
-- Limpa variaveis quando sair (evitar o uso delas no futuro)
|
||||
if fields.quit then
|
||||
multichat.online[player:get_player_name()].sl_tb_online = nil
|
||||
multichat.online[player:get_player_name()].sl_tb_grupo = nil
|
||||
-- Verifica seleções
|
||||
elseif fields.online then
|
||||
multichat.online[player:get_player_name()].sl_tb_online = string.split(fields.online, ":")[2]
|
||||
elseif fields.grupo then
|
||||
multichat.online[player:get_player_name()].sl_tb_grupo = string.split(fields.grupo, ":")[2]
|
||||
|
||||
-- Voltar ao menu principal
|
||||
elseif fields.voltar then
|
||||
multichat.acessar_menu(player:get_player_name())
|
||||
return
|
||||
|
||||
-- Adicionar jogador para conversar
|
||||
elseif fields.adicionar then
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verifica se tem algum jogador na tabela
|
||||
if table.maxn(multichat.online[name].tb_online) == 0 then return end
|
||||
|
||||
-- Verifica se selecionou umjogador
|
||||
if not tonumber(multichat.online[name].sl_tb_online) then return end
|
||||
|
||||
-- Caso o grupo esteja vazio cria
|
||||
if multichat.grupos[name] == nil then multichat.grupos[name] = {} end
|
||||
|
||||
-- Adiciona jogador
|
||||
local sl = tonumber(multichat.online[name].sl_tb_online)
|
||||
local grupo = multichat.online[name].tb_online[sl]
|
||||
multichat.grupos[name][grupo] = true
|
||||
|
||||
-- Atualiza menu do grupo
|
||||
acessar_menu_grupo(name)
|
||||
|
||||
return
|
||||
|
||||
-- Remover jogador
|
||||
elseif fields.remover then
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verifica se tem algum jogador na tabela
|
||||
if table.maxn(multichat.online[name].tb_grupo) == 0 then return end
|
||||
|
||||
-- Verifica se selecionou umjogador
|
||||
if not tonumber(multichat.online[name].sl_tb_grupo) then return end
|
||||
|
||||
-- Remove jogador do grupo
|
||||
local sl = tonumber(multichat.online[name].sl_tb_grupo)
|
||||
if multichat.grupos[name] ~= nil
|
||||
and multichat.online[name].tb_grupo ~= nil
|
||||
and multichat.online[name].tb_grupo[sl] ~= nil
|
||||
then
|
||||
multichat.grupos[name][multichat.online[name].tb_grupo[sl]] = nil
|
||||
end
|
||||
|
||||
-- Atualiza menu do grupo
|
||||
acessar_menu_grupo(name)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
-- Registrar em 'sfinv'
|
||||
if mymenu then
|
||||
|
||||
-- Registrar metodo de tradução instantanea
|
||||
mymenu.register_tr(SS)
|
||||
|
||||
-- Registrar botao
|
||||
mymenu.register_button("multichat:abrir_menu", S("Bate-Papo"))
|
||||
|
||||
-- Receber botao do inventario
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields["multichat:abrir_menu"] then
|
||||
multichat.acessar_menu(player:get_player_name())
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
if minetest.global_exists("sfinv_menu") then
|
||||
sfinv_menu.register_button("multichat:menu", {
|
||||
title = S("Bate-Papo"),
|
||||
icon = "multichat_botao.png",
|
||||
func = function(player)
|
||||
multichat.acessar_menu(player:get_player_name())
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.global_exists("unified_inventory") then
|
||||
unified_inventory.register_button("multichat:menu", {
|
||||
type = "image",
|
||||
image = "multichat_botao.png",
|
||||
tooltip = S("Bate-Papo"),
|
||||
action = function(player)
|
||||
multichat.acessar_menu(player:get_player_name())
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
|
2
mod.conf
2
mod.conf
|
@ -1 +1,3 @@
|
|||
name = multichat
|
||||
depends = default
|
||||
optional_depends = irc,sfinv,mymenu,manipulus,sfinv_menu,unified_inventory
|
||||
|
|
124
msg.lua
124
msg.lua
|
@ -1,62 +1,62 @@
|
|||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ajuste no comando /msg
|
||||
|
||||
]]
|
||||
|
||||
local som_avisar = multichat.som_avisar
|
||||
|
||||
local old_func = minetest.chatcommands.msg.func
|
||||
|
||||
function minetest.chatcommands.msg.func(name, param)
|
||||
local sendto, message = param:match("^(%S+)%s(.+)$")
|
||||
if not sendto then
|
||||
return false, "Invalid usage, see /help msg."
|
||||
end
|
||||
|
||||
local ouvinte = sendto
|
||||
|
||||
-- Verifica o jogador pode ouvir
|
||||
if minetest.player_exists(ouvinte) and minetest.get_player_by_name(ouvinte) then
|
||||
local player = minetest.get_player_by_name(ouvinte)
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
som_avisar(name)
|
||||
return true, "Message sent." -- Tenta enganar jogador que enviou a mensagem
|
||||
|
||||
-- Verifica se jogador está ouvindo apenas seu grupo
|
||||
elseif status == "grupo" and multichat.grupos[ouvinte] then
|
||||
|
||||
-- Verifica se falante está no grupo
|
||||
if multichat.grupos[name][falante] == nil then
|
||||
som_avisar(name)
|
||||
return true, "Message sent." -- Tenta enganar jogador que enviou a mensagem
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local r, msg = old_func(name, param)
|
||||
|
||||
if r == true then
|
||||
if ouvinte == name then
|
||||
som_avisar(name)
|
||||
else
|
||||
som_avisar(ouvinte, message)
|
||||
som_avisar(name)
|
||||
end
|
||||
end
|
||||
|
||||
return r, msg
|
||||
end
|
||||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ajuste no comando /msg
|
||||
|
||||
]]
|
||||
|
||||
local som_avisar = multichat.som_avisar
|
||||
|
||||
local old_func = minetest.chatcommands.msg.func
|
||||
|
||||
function minetest.chatcommands.msg.func(name, param)
|
||||
local sendto, message = param:match("^(%S+)%s(.+)$")
|
||||
if not sendto then
|
||||
return false, "Invalid usage, see /help msg."
|
||||
end
|
||||
|
||||
local ouvinte = sendto
|
||||
|
||||
-- Verifica o jogador pode ouvir
|
||||
if minetest.player_exists(ouvinte) and minetest.get_player_by_name(ouvinte) then
|
||||
local player = minetest.get_player_by_name(ouvinte)
|
||||
local status = player:get_attribute("multichat_status")
|
||||
|
||||
-- Verifica se o jogador está no bate-papo público
|
||||
if status == nil or status == "pub" then
|
||||
|
||||
-- Verificar se está desativado
|
||||
elseif status == "off" then
|
||||
som_avisar(name)
|
||||
return true, "Message sent." -- Tenta enganar jogador que enviou a mensagem
|
||||
|
||||
-- Verifica se jogador está ouvindo apenas seu grupo
|
||||
elseif status == "grupo" and multichat.grupos[ouvinte] then
|
||||
|
||||
-- Verifica se falante está no grupo
|
||||
if multichat.grupos[name][falante] == nil then
|
||||
som_avisar(name)
|
||||
return true, "Message sent." -- Tenta enganar jogador que enviou a mensagem
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local r, msg = old_func(name, param)
|
||||
|
||||
if r == true then
|
||||
if ouvinte == name then
|
||||
som_avisar(name)
|
||||
else
|
||||
som_avisar(ouvinte, message)
|
||||
som_avisar(name)
|
||||
end
|
||||
end
|
||||
|
||||
return r, msg
|
||||
end
|
||||
|
|
50
online.lua
50
online.lua
|
@ -1,25 +1,25 @@
|
|||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- Controle de jogadores online
|
||||
]]
|
||||
|
||||
|
||||
-- Jogadores online
|
||||
|
||||
multichat.online = {}
|
||||
|
||||
-- Adiciona jogador ao entrar
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
multichat.online[player:get_player_name()] = {}
|
||||
end)
|
||||
|
||||
-- Remove nome do jogador ao sair
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
multichat.online[player:get_player_name()] = nil
|
||||
end)
|
||||
--[[
|
||||
Mod MultiChat para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- Controle de jogadores online
|
||||
]]
|
||||
|
||||
|
||||
-- Jogadores online
|
||||
|
||||
multichat.online = {}
|
||||
|
||||
-- Adiciona jogador ao entrar
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
multichat.online[player:get_player_name()] = {}
|
||||
end)
|
||||
|
||||
-- Remove nome do jogador ao sair
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
multichat.online[player:get_player_name()] = nil
|
||||
end)
|
||||
|
|
|
@ -5,12 +5,3 @@ multichat_admin_prefix (Prefixo usado para administradores no chat) string ADMIN
|
|||
|
||||
# Aparece para jogadores com o provilegio chat_staff.
|
||||
multichat_staff_prefix (Prefixo usado para moderadores no chat) string MODERADOR
|
||||
|
||||
# A cada certo tempo todos os dados de bate-papo privado
|
||||
# de jogadores que estejam offline sao removidos para manter a memoria
|
||||
# limpa.
|
||||
# Tempo dado em segundos.
|
||||
multichat_tempo_verif_grupo (Tempo para verificar grupos) int 3600
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue