remoção da lib memor
parent
f92204677b
commit
383bf8b5b0
6
init.lua
6
init.lua
|
@ -32,11 +32,7 @@ local modpath = minetest.get_modpath("multichat")
|
|||
|
||||
-- Carregar scripts
|
||||
notificar("Carregando...")
|
||||
dofile(modpath.."/lib/memor/init.lua")
|
||||
|
||||
-- Variavel temporaria de jogadores online
|
||||
multichat.online = memor.online()
|
||||
|
||||
dofile(modpath.."/online.lua")
|
||||
dofile(modpath.."/chat.lua")
|
||||
dofile(modpath.."/menu.lua")
|
||||
dofile(modpath.."/msg.lua")
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
API
|
||||
|
||||
===================================> Montar um banco de dados rápido <===================================
|
||||
Esse banco de dados fica em uma subpasta com o nome do mod especificado portanto não deve existir nenhum
|
||||
arquivo ou pasta com o nome do mod dentro da pasta do mundo pois isso ocasionaria um conflito de nomes
|
||||
|
||||
memor.montar_bd(<nome do mod>) -- Função que retorna uma tabela de funções para gerenciar o banco de
|
||||
dados do mod
|
||||
|
||||
<nome do mod> OPCIONAL é o nome do mod que usará o banco de dados
|
||||
Se nulo, fica sendo o nome do mod que executar a função
|
||||
|
||||
Chamadas de função para o banco de dados criado
|
||||
|
||||
salvar(tb, index, valor) -- Salva um valor no banco de dados (cria as tabelas se não existirem)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
<valor> é o valor armazenado (exemplo: 6, 30, "Caio")
|
||||
|
||||
pegar(index, valor) -- Retorna o valor armazenado (ou nulo caso seja inexistente)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
|
||||
verif(index, valor) -- Verifica se um determinado registro existe (retorna 'true' se existir)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
|
||||
remover(tb, index) -- Remove um valor da tabela (apaga o dado armazenado)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
|
||||
drop_tb(tb) -- Remove uma tabela (apagando todos os seus dados)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
|
||||
listar(tb) -- Retorna uma tabela ordenada com strings dos nomes de tabelas ou indices
|
||||
|
||||
<tb> OPICIONAL é uma tabela a qual desejar listar os sues indices
|
||||
^ Se nulo, retorna as listagem das tabelas do banco de dados
|
||||
|
||||
Exemplo de uso:
|
||||
|
||||
-- Montar um banco de dados na variavel 'registro'
|
||||
local registro = memor.montar_bd(minetest.get_current_modname())
|
||||
|
||||
-- Criar uma tabela de "medalhas" onde "Maria" terá 15
|
||||
registro:salvar("medalhas", "Maria", 15)
|
||||
|
||||
-- Verifica se "Maria" existe na tabela de "Medalhas"
|
||||
if registro:verif("medalhas", "Maria") then
|
||||
|
||||
-- Consulta quantas "medalhas" "Maria" tem
|
||||
local medalhas = registro:pegar("medalhas", "Maria") -- retorna 15
|
||||
|
||||
minetest.chat_send_all("Maria tem " .. medalhas .. " medalhas")
|
||||
|
||||
end
|
||||
|
||||
-- Remover "Maria" da tabela "medalhas"
|
||||
registro:remover("medalhas", "Maria")
|
||||
|
||||
-- Remove a tabela "medalhas"
|
||||
registro:drop_tb("medalhas")
|
||||
|
||||
=========================================================================================================
|
||||
|
||||
=====================================> Tabela de jogadores online <======================================
|
||||
|
||||
memor.online(<nome do mod>) -- Retorna uma tabela desordenada com índices com nomes dos jogadores online
|
||||
^ A tabela só mantém dados dos índices de jogadores online
|
||||
^ Caso um nome de jogador que não esteja online for inserido, ele vai
|
||||
ser apagado assim que algum jogador sair do servidor
|
||||
|
||||
<nome do mod> OPCIONAL é uma string com o nome do mod dono da tabela (o que opera a tabela)
|
||||
Se nulo, fica sendo o nome do mod que executar a função
|
||||
|
||||
Exemplo de uso:
|
||||
|
||||
-- Tabela que guarda quem é o convidado de um jogador (controlada para manter apenas jogadores online)
|
||||
local convidados = memor.online()
|
||||
|
||||
-- Jogador "Arnaldo" tem "Luiz" como convidado
|
||||
convidados["Arnaldo"] = "Luiz"
|
||||
|
||||
-- Quando o jogador "Arnaldo" sair do servidor, esse dado será apagado da memória
|
||||
|
||||
=========================================================================================================
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
|
@ -1,9 +0,0 @@
|
|||
# Memor v1.2
|
||||
|
||||
por BrunoMine
|
||||
|
||||
Gerencia dados rápidos de forma simples em formato de banco de dados ou tabela de dados temporários.
|
||||
|
||||
LICENÇA LGPL v3
|
||||
|
||||
Memor é um software livre; você pode redistribuí-lo e/ou modificá-lo dentro dos termos da Licença Pública Geral Menor GNU como publicada pela Fundação do Software Livre (FSF); na versão 3 da Licença, ou (na sua opinião) qualquer versão. Este programa é distribuído na esperança de que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral Menor GNU para maiores detalhes. Você deve ter recebido uma cópia da Licença Pública Geral Menor GNU junto com este programa, se não, veja http://www.gnu.org/licenses/.
|
|
@ -1,105 +0,0 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Operadores de arquivamento e leitura
|
||||
]]
|
||||
|
||||
|
||||
-- Diretorio do mundo
|
||||
local wpath = minetest.get_worldpath()
|
||||
|
||||
-- Cria um diretório na pasta do mundo
|
||||
function memor.mkdir(dir, sub)
|
||||
if not dir then
|
||||
minetest.log("error", "[Memor] Nenhum diretorio especificado (em memor.mkdir)")
|
||||
return false
|
||||
end
|
||||
|
||||
dir = wpath.."/"..dir
|
||||
|
||||
if minetest.mkdir then
|
||||
minetest.mkdir(dir)
|
||||
else
|
||||
os.execute('mkdir "' .. dir .. '"')
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Criar um arquivo com os dados serializados (Salvar)
|
||||
function memor.escrever(mod, dir, arquivo, dados)
|
||||
if mod == nil or dir == nil or arquivo == nil or dados == nil then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.escrever)")
|
||||
return false
|
||||
end
|
||||
|
||||
local dados = minetest.serialize(dados)
|
||||
if dados == "" then
|
||||
minetest.log("error", "[Memor] Dado fornecido invalido (em memor.escrever)")
|
||||
return false
|
||||
end
|
||||
|
||||
local saida = io.open(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo, "w")
|
||||
if saida then
|
||||
saida:write(dados)
|
||||
io.close(saida)
|
||||
return true
|
||||
else
|
||||
minetest.log("info", "[Memor] memor.escrever tentou escrever num diretorio inexistente")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Ler dados de um arquivo de memória (Carregar)
|
||||
function memor.ler(mod, dir, arquivo)
|
||||
if mod == nil or dir == nil or arquivo == nil then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.ler)")
|
||||
return nil
|
||||
end
|
||||
|
||||
local entrada = io.open(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo, "r")
|
||||
if entrada then
|
||||
local dados = entrada:read("*l")
|
||||
if dados ~= "" or dados ~= nil then
|
||||
dados = minetest.deserialize(dados)
|
||||
end
|
||||
io.close(entrada)
|
||||
return dados
|
||||
else
|
||||
minetest.log("error", "[Memor] pasta e/ou arquivo inexiste(s) (em memor.ler)")
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Deletar um arquivo
|
||||
function memor.deletar(mod, dir, arquivo)
|
||||
if not mod or not dir or not arquivo then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.deletar)")
|
||||
return false
|
||||
end
|
||||
|
||||
os.remove(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
-- Deletar um diretório
|
||||
function memor.deletar_dir(mod, dir)
|
||||
if not mod or not dir then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.deletar_dir)")
|
||||
return false
|
||||
end
|
||||
|
||||
local list = minetest.get_dir_list(wpath .. "/" .. mod .. "/" .. dir)
|
||||
|
||||
for n, arquivo in ipairs(list) do
|
||||
os.remove(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo)
|
||||
end
|
||||
|
||||
os.remove(wpath .. "/" .. mod .. "/" .. dir)
|
||||
return true
|
||||
end
|
|
@ -1,129 +0,0 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Operadores de consulta
|
||||
]]
|
||||
|
||||
-- Diretório do Mundo
|
||||
local wpath = minetest.get_worldpath()
|
||||
|
||||
-- Verifica diretorios e corrige
|
||||
verificar = function(dir, subdir)
|
||||
|
||||
-- Verifica e corrige diretorio
|
||||
local list = minetest.get_dir_list(minetest.get_worldpath(), true)
|
||||
local r = false
|
||||
for n, ndir in ipairs(list) do
|
||||
if ndir == dir then
|
||||
r = true
|
||||
break
|
||||
end
|
||||
end
|
||||
-- Diretorio inexistente
|
||||
if r == false then
|
||||
memor.mkdir(dir)
|
||||
end
|
||||
|
||||
-- Verifica e corrige subdiretorio
|
||||
list = minetest.get_dir_list(minetest.get_worldpath().."/"..dir, true)
|
||||
r = false
|
||||
for n, ndir in ipairs(list) do
|
||||
if ndir == subdir then
|
||||
r = true
|
||||
break
|
||||
end
|
||||
end
|
||||
-- Subdiretorio inexistente
|
||||
if r == false then
|
||||
memor.mkdir(dir.."/"..subdir)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Inserir dados
|
||||
memor.inserir = function(mod, tb, index, valor)
|
||||
|
||||
-- Tenta inserir direto
|
||||
if memor.escrever(mod, tb, index, valor) == true then return true end
|
||||
|
||||
verificar(mod, tb)
|
||||
|
||||
if memor.escrever(mod, tb, index, valor) then
|
||||
return true
|
||||
else
|
||||
minetest.log("error", "[Memor] Impossivel salvar dados (em memor.inserir)")
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Ler dados
|
||||
memor.consultar = function(mod, tb, index)
|
||||
|
||||
local r = memor.ler(mod, tb, index)
|
||||
if r == nil then
|
||||
minetest.log("error", "[Memor] Registro acessado inexistente ("..dump(mod).."/"..dump(tb).."/"..dump(index)..") (em memor.consultar)")
|
||||
end
|
||||
|
||||
return r
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Verificar dados
|
||||
memor.verificar = function(dir, subdir, arquivo)
|
||||
|
||||
list = minetest.get_dir_list(wpath .. "/" .. dir .. "/" .. subdir)
|
||||
r = false
|
||||
for n, arq in ipairs(list) do
|
||||
if arq == arquivo then
|
||||
r = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if r then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Listar
|
||||
memor.listar = function(dir, subdir)
|
||||
if dir == nil then
|
||||
minetest.log("error", "[Memor] Diretorio inexistente (em memor.listar)")
|
||||
return false
|
||||
end
|
||||
|
||||
if subdir then
|
||||
|
||||
local list = minetest.get_dir_list(wpath .. "/" .. dir .. "/" .. subdir)
|
||||
|
||||
if list == nil then
|
||||
minetest.log("error", "[Memor] Impossivel listar diretorio (em memor.listar)")
|
||||
return false
|
||||
else
|
||||
return list
|
||||
end
|
||||
|
||||
else
|
||||
local list = minetest.get_dir_list(wpath .. "/" .. dir)
|
||||
|
||||
if list == nil then
|
||||
minetest.log("error", "[Memor] Impossivel listar diretorio (em memor.listar)")
|
||||
return false
|
||||
else
|
||||
return list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Inicializador de scripts
|
||||
]]
|
||||
|
||||
-- Verifica se o mod memor original esta ativo
|
||||
if minetest.get_modpath("memor") then return end
|
||||
|
||||
|
||||
-- Notificador de Inicializador
|
||||
local notificar = function(msg)
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.debug("[MEMOR]"..msg)
|
||||
end
|
||||
end
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. "/lib/memor"
|
||||
|
||||
-- Variavel global
|
||||
memor = {}
|
||||
|
||||
-- Carregar scripts
|
||||
notificar("Carregando scripts...")
|
||||
dofile(modpath.."/arquivo.lua")
|
||||
dofile(modpath.."/consulta.lua")
|
||||
dofile(modpath.."/montagem.lua")
|
||||
dofile(modpath.."/online.lua")
|
||||
notificar("OK")
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Montagem de bando de dados
|
||||
]]
|
||||
|
||||
|
||||
-- Montar banco de dados em um mod
|
||||
function memor.montar_bd(mod)
|
||||
v = {}
|
||||
v.mod = mod or minetest.get_current_modname()
|
||||
|
||||
-- Inserir dados
|
||||
v.salvar = function(v, tb, index, valor)
|
||||
return memor.inserir(v.mod, tb, index, valor)
|
||||
end
|
||||
|
||||
-- Consultar dados
|
||||
v.pegar = function(v, tb, index)
|
||||
return memor.consultar(v.mod, tb, index)
|
||||
end
|
||||
|
||||
-- Verificar dados
|
||||
v.verif = function(v, tb, index)
|
||||
return memor.verificar(v.mod, tb, index)
|
||||
end
|
||||
|
||||
-- Remover dados
|
||||
v.remover = function(v, tb, index)
|
||||
return memor.deletar(v.mod, tb, index)
|
||||
end
|
||||
|
||||
-- Remover tabela
|
||||
v.drop_tb = function(v, tb)
|
||||
return memor.deletar_dir(v.mod, tb)
|
||||
end
|
||||
|
||||
-- Listar dados
|
||||
v.listar = function(v, tb)
|
||||
return memor.listar(v.mod, tb)
|
||||
end
|
||||
|
||||
return v
|
||||
end
|
|
@ -1,45 +0,0 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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
|
||||
]]
|
||||
|
||||
|
||||
-- Controle de jogadores de cada mod
|
||||
memor.online_mods = {}
|
||||
|
||||
-- Montar banco de dados simples de jogadores online
|
||||
function memor.online(mod)
|
||||
local mod = mod or minetest.get_current_modname()
|
||||
|
||||
memor.online_mods[mod] = {}
|
||||
|
||||
return memor.online_mods[mod]
|
||||
end
|
||||
|
||||
-- Adiciona o jogador em todas listas quando entrar no servidor
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
for mod,l in pairs(memor.online_mods) do
|
||||
memor.online_mods[mod][player:get_player_name()] = {}
|
||||
end
|
||||
end)
|
||||
|
||||
-- Remove o jogador de todas listas quando entrar no servidor
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
for mod,l in pairs(memor.online_mods) do
|
||||
local np = {}
|
||||
for _,p in ipairs(minetest.get_connected_players()) do
|
||||
local n = p:get_player_name()
|
||||
if n ~= name then
|
||||
np[n] = memor.online_mods[mod][n]
|
||||
end
|
||||
end
|
||||
memor.online_mods[mod] = np
|
||||
end
|
||||
end)
|
|
@ -0,0 +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)
|
Loading…
Reference in New Issue