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