diff --git a/API.txt b/API.txt new file mode 100644 index 0000000..2bafca7 --- /dev/null +++ b/API.txt @@ -0,0 +1,312 @@ +API para mod Xpro v1.0.0 + +### Métodos + +* `xpro.add_xp(name, xp_add)` + * Adiciona xp a um jogador +* `xpro.register_on_add_xp(func(name, xp_added, lvl_changed))` + * Registra uma função a ser executada apos ser adicionado xp a um jogador +* `xpro.rem_xp(name, xp_rem)` + * Remove xp a um jogador +* `xpro.register_on_rem_xp(func(name, xp_removed, lvl_changed))` + * Registra uma função a ser executada apos ser removido xp de um jogador +* `xpro.get_player_xp(name)` + * Retorna o numero de pontos de xp do jogador +* `xpro.get_player_lvl(name)` + * Retorna o numero do nivel do jogador + + + + + + + + + + + + + + + + +- +- +- exemplos (apagar depois) +- +- + +### Métodos + +* `aventuras.registrar_personagem(IdPersonagem, Definições de personagem)` + * Registra um personagem + * `IdPersonagem` é ID que representa o personagem + (exemplo, se for npc esse será o nome da entidade registrada) + +* `aventuras.registrar_aventura(Aventura, Definições de aventura)` + * Registrar uma aventura + * `Aventura` é o nome da aventura (exemplo: "nome_mod:grande_desbravador") + +* `aventuras.adicionar_tarefa(Aventura, Definições de tarefa)` + * Adicionar uma tarefa em uma aventura + +* `aventuras.pegar_tarefa(NomeJogador, Aventura)` + * Retorna o número da última tarefa realizada + * Retorna `0` caso não tenha feito nenhuma + +* `aventuras.salvar_tarefa(NomeJogador, Aventura, Tarefa)` + * Salva a ultima tarefa realizada por um jogador + * `Tarefa` é o numero da tarefa + +* `aventuras.registrar_item_bau_noob(ItemString, Definições do item noob)` + * Registra um item para ser comprado por jogadores quando estiverem numa tarefa especifica + * O nome Item Noob é defido ao fato do item ser destinado aos jogadores que perderam o item + que seria usado na proxima etapa da tarefa. + * `ItemString` é o itemstring do item (exemplo: "mymod:bilhete_1") + +* `aventuras.comum.verif_tarefa(Aventura, Tarefa)` + * Verifica se uma tarefa existe + +* `avesturas.registrar_estrutura(Estrutura, Definições de estrutura)` + * Registra uma estrutura para ser construida no mundo + * `Estrutura` é o nome da estrutura (exemplo: "modname:castelo") + +* `aventuras.registrar_lugar(Lugar, Definições de lugar)` + * Isso é usado pelo balao de aventureiro para que jogadores acessem lugares relacionados a aventuras + +### Funções de registo de chamada global (callbacks) + +* `aventuras.callbacks.registrar_ao_concluir(function(NomeJogador, Aventura, Tarefa))` + * Chamada quando um jogador conclui uma tarefa + +## Definições de estrutura +{ + titulo = "Castelo Real", -- Titulo exibido ao jogador + + versao = "1", --[[ + ^ Versao da estrutura + ^ Quando uma estrutura é montada no mundo, a versao é gravada + ^ Isso é usado apenas como string + ^ Quando for diferente da versao gravada a estrutura é remontada no mesmo local ]] + + altura = 10, -- Altura da estrutura + + largura = 21, -- Largura da estrutura + + filepath = minetest.get_modpath(minetest.get_current_modname()).."/schems/castelo.mts", --[[ + ^ Caminho do arquivo no formato schematic de minetest onde a estrutura está armazenada ]] + + mapgen = { -- Dados para definir como a estrutura será gerada no mundo + + tipo = "tipo", --[[ + ^ Tipo de posicionamento da estrutura no mapa gerado + ^ No tipo "suspenso" a estrutura será colocada 3 blocos acima do bloco mais + alto numa area gerada aleatoriamente no mapa + ^ em bioma "floresta" a estrutura aparece acima de arvores comuns + ^ em bioma "campo" a estrutura aparece acima de uma area plana de terra com grama ]] + + bioma = "bioma", --[[ + ^ Bioma da area onde a estrutura é montada + ^ Para detalhes dos biomas, verifique o `tipo` utilizado na mapgen da estrutura utilizado ]] + }, +} + +### Definições do item noob (`registrar_item_bau_noob`) +{ + aventura = "mymod:aventura_exemplo", -- Aventura relacionada + + tarefa = 10, -- Tarefa que o jogador deve ter realizado por ultimo (onde o mesmo recebe o item) + + desc_item = "Apple", -- Descrição do item no menu + + custo = 1, --[[ OPCIONAL + ^ Custo da compra + ^ O item é definido com a definição aventuras_moeda_bau_noob + ^ Se nulo, é definido como 1 ]] + + give_item = func(player), --[[ OPCIONAL + ^ Função que da o item ao jogador + ^ Se nulo, uma unidade é dada ao jogador ]] +} + +### Definições de personagem (`registrar_personagem`) +{ + type = "npc", --[[ + ^ Tipo do personagem + ^ "npc" para NPCs (entidades Lua)]] + + npc_preset = "human", --[[ + ^ Predefinição da entidade a ser criada + ^ "human" para ser predefinido como um humano]] + + npc = { -- Caracteristicas da entidade Lua + + textures = { --[[ + ^ Texturas da entidade + ^ Se voce deseja que a entidade use texturas alternativas + precisa lista-las como abaixo]] + {"texture.png"}, + {"texture.1.png"}, + {"texture.2.png"}, + }, + + sounds = { --[[ + ^ Sons da entidade + ^ Não precisa listar todos os sons alternativos]] + random = "sound", -- Som emitido aleatoriamente pela entidade + }, + + }, + + arte_npc = Definições de arte de NPC, -- Arte do NPC + + spawner_node = { --[[ + ^ Nodes que spawnadores do npc + ^ Os NPCs surgem proximos aos nodes + ["aventuras_tomas:bau"] = { + spawn_mode = "front", --[[ + ^ Maneira como o NPC spawna pelo node + ^ "front" spawna em frente ao node (um bloco de distancia) + }, + }, + + random_spawn = { --[[ + ^ Spawn aleatorio + ^ NPCs que spawnam aleatoriamente duram um tempo limitado no mapa e desaparecem]] + + nodes = {"nodename1", "nodename2"}, -- Tabela de nodes + min_light = 10, -- OPCIONAL | Luminosidade minima do local (se omitido, sera 10) + chance = 15000, -- OPCIONAL | Chance de spawn ocorrer (se omitido, sera 15000) + active_object_count = 1, -- OPCIONAL | Limite de mobs por blocos de mapa (se omitido, sera 1) + min_height = 0, -- OPCIONAL | Altura minima para spawn ocorrer (se omitido, sera 0) + day_toggle = true, --[[ OPCIONAL | Define se deve estar de dia ou de noite + ^ `true` para spawn apenas de dia + ^ `false` para spawn apenas de noite + ^ `nil` para qualquer momento]] + } +} + +### Definições de aventura +{ + titulo = "Grande Desbravador", -- Titulo da aventura + desc = "Uma aventura legal", -- Pequena descrição da aventura + img = "default_apple.png", -- [OPCIONAL] Imagem (quadrada) que representa a aventura +} + +### Definições de tarefa +{ + titulo = "Descobrindo o mundo", -- Titulo da tarefa + + tipo = "info_npc" --[[ + ^ "npc_info" o jogador deve falar com um NPC + ^ "npc_troca" o jogador deve trocar itens com um NPC + ^ "npc_place_node" o jogador deve colocar um node após falar com um NPC + ^ "npc_dig_node" o jogador deve quebrar um node após falar com um NPC + ^ "npc_comida" o jogador deve comer algo apos falar com um NPC + ^ "npc_craft" o jogador deve craftar algo apos falar com um NPC ]] + + dados = { -- Tabela de dados que o referido tipo de tarefa designar + + aven_req = {["uma_aventura"]=2,["outra_aventura"]=10}, --[[ + ^ Exige que o jogador tenha concluido algumas tarefas de outras aventuras ]] + + npcs = {"mobs_npc:igor", "mobs_npc:trader"}, --[[ + ^ Tabela de entidades que possibilitam a realização da tarefa ]] + + item_rem = Tabela de Itens, --[[ + ^ Usado para tarefas do tipo "npc_troca" + ^ Tabela de itens exigidos para a troca (limite de 5 itens na tabela) ]] + + item_add = Tabela de Itens, --[[ + ^ Usado para tarefas do tipo "npc_troca" + ^ Tabela de itens recebidos pela troca (limite de 5 itens na tabela) ]] + + item = "", --[[ + ^ Itemstring de um item + ^ Na tarefa do tipo "npc_place" o jogador deve colocar o node informado aqui + ^ Na tarefa do tipo "npc_dig" o jogador deve quebrar o node informado aqui + ^ Na tarefa do tipo "npc_craft" o jogador deve craftar o item informado aqui + ^ Na tarefa do tipo "npc_comida" o jogador deve comer o alimento informado aqui ]] + + img_item = "aventuras_tarefa_duvida.png" --[[ + ^ OPCIONAL + ^ Nome de um arquivo de imagem + ^ Quando informado, essa imagem fica no lugar da imagem do `item` informado acima ]] + + msg = "", -- Mensagem apresentada pelo NPC quando o jogador acessa inicialmente + + msg_fim = "", --[[ + ^ Mensagem apresentada quando o jogador conclui a tarefa + ^ Caso o jogador esteja em uma interação com o NPC, essa mensagem será a fala do NPC + ^ Caso o jogador não esteja interagindo com o NPC no momento da conclusão, + a mensagem é exibida do console do chat (como nas tarefas do tipo "npc_craft" e "npc_food") + }, +} + + +### Tabela de Itens +{ + {name="default:dirt", count=50, wear=0, metadata=""}, + {name="default:sand", count=5, wear=0, metadata=""}, + {name="default:cobble", count=1, wear=0, metadata=""}, +} + +Recursos +-------- + +### NPCs +* `aventuras.recursos.npc.registrar(nome, aventura)` : Registrar o uso de um NPC na engine + * `nome` é o nome da entidade-NPC (exemplo: "mobs_npc:igor") + * `aventura` é o nome da aventura (exemplo: "nome_mod:grande_desbravador") + * Executa a chamada `aventuras.tarefas["tipo de tarefa"].npcs.on_rightclick(npc_name, clicker, aventura, tarefa)` quando o npc é acessado e o jogador está na tarefa cujo registro possui `npcs.on_rightclick["nome da entidade"]` + +* `aventuras.recursos.npc.on_rightclick(self, clicker)` : Coordena o chamada 'on_rightclick' no NPC + * São os mesmo argumentos da chamada 'on_rightclick' + +* `aventuras.recursos.npc.registrar_arte(nome, Definições de arte de NPC)` : Registra dados de arte do npc + * `nome` é o nome da entidade-NPC (exemplo: "mobs_npc:igor") + +### Definições de arte de NPC +{ + face = "default_dirt.png", + ^ Imagem da face do NPC para as formspecs de apresentação (recomenda-se largura e altura iguais) + bgcolor = "bgcolor[#080808BB;true]", + ^ Valor RGB-Hexadecimal da cor de fundo para as formspecs de apresentação + bg_img1x1 = "background[5,5;1,1;gui_formbg.png;true]", + ^ Imagem de fundo para as formspecs no formato quadrado + bg_img10x3 = "background[5,5;1,1;gui_formbg.png;true]", + ^ Imagem de fundo para as formspecs no formato 10x3 + sounds = Sons de NPC, + ^ Opcional. Tabela de sons do NPC +} + +### Definições de lugar +{ + titulo = "Castelo Real", -- Titulo exibido ao jogador + pos = {x=0,y=0,z=0}, -- Coordenada para onde o jogador é teleportado quando for ao lugar + aven_req = {["uma_aventura"]=2,["outra_aventura"]=10}, -- OPICIONAL | Tarefas de aventuras exigidas para teleportar para o lugar +} + +### Sons de NPC +{ + concluir = {name="aventuras_concluir",gain=1.0}, + ^ Nome do arquivo de audio de quando o jogador conclui uma tarefa no NPC +} + +Banco de Dados +-------------- +O banco de dados utilizado pela API é o Memor. Veja a documentação especifica para este. + +A estrutura dos dados é feita da seguinte forma: + +mundo + --aventuras + |--editor_schem + | --acessos (dados de acessos) + | + --player_ + |--aventura_ (ultima tarefa realizada) + |--tarefa_ (dados de processamento da tarefa) + --livro_de_aventuras (dados do livro de aventuras do jogador) + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. diff --git a/README.md b/README.md index 39c7549..e6b6ac7 100644 --- a/README.md +++ b/README.md @@ -1 +1,26 @@ -xpro +# Xpro v1.1.0 +[![download](https://img.shields.io/github/tag/BrunoMine/xpro.svg?style=flat-square&label=release)](https://github.com/BrunoMine/xpro/archive/v1.1.0.zip) +[![git](https://img.shields.io/badge/git-project-green.svg?style=flat-square)](https://github.com/BrunoMine/xpro) +[![forum](https://img.shields.io/badge/minetest-mod-green.svg?style=flat-square)](https://forum.minetest.net) +[![bower](https://img.shields.io/badge/bower-mod-green.svg?style=flat-square)](https://minetest-bower.herokuapp.com/mods/xpro) + +## Descrição _Description_ +Sistema de niveis e experiencia + +## Requisitos _(Requirements)_ +* Minetest 0.4.17 ou superior +* Mod default +* Mod sfinv +* Mod intllib (opicional) + +## Licença _(License)_ +Veja LICENSE.txt para informações detalhadas da licença LGPL 3.0 + +### Autores do código fonte +Originalmente por BrunoMine, Bruno Borges (LGPL 3.0) + +### Autores de mídias (texturas, modelos and sons) + +Todas que não estão descritas aqui são de autoria de +BrunoMine, Bruno Borges (CC BY-SA 3.0) + diff --git a/api.lua b/api.lua new file mode 100644 index 0000000..ae2425f --- /dev/null +++ b/api.lua @@ -0,0 +1,152 @@ +--[[ + Mod Xpro 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 . + + API + ]] + +-- Niveis de acoordo com XP +local tb_niveis = { + 0, -- Nivel 1 + 150, -- Nivel 2 + 300, -- Nivel 3 + 600, -- Nivel 4 + 900, -- Nivel 5 + 1200, -- Nivel 6 + 1500, -- Nivel 7 + 2000, -- Nivel 8 + 2500, -- Nivel 9 + 3000, -- Nivel 10 + 3500, -- Nivel 11 + 4000, -- Nivel 12 + 4600, -- Nivel 13 + 5200, -- Nivel 14 + 6000, -- Nivel 15 + 6900, -- Nivel 16 + 8000, -- Nivel 17 +} + +-- Pegar nivel de acordo com XP +local get_lvl = function(my_xp) + local my_lvl = 1 + for lvl,xp in ipairs(tb_niveis) do + if xp > my_xp then + return my_lvl -- Retorna o nivel anterior + end + -- Tem o xp necessario para esse nivel + my_lvl = lvl + end + return my_lvl +end + +-- Pegar xp de um jogador (informar) +xpro.get_player_xp = function(name) + return xpro.bd.pegar("jogador_"..name, "xp") +end + +-- Pegar nivel de um jogador (informar) +xpro.get_player_lvl = function(name) + return xpro.bd.pegar("jogador_"..name, "lvl") +end + + +-- Registro basico +minetest.register_on_joinplayer(function(player) + + -- Verifica se jogador ja possui registro no BD + if xpro.bd.verif("jogador_"..player:get_player_name(), "xp") ~= true then + + -- Criar registro + local tb_name = "jogador_"..player:get_player_name() + + -- XP + xpro.bd.salvar(tb_name, "xp", 0) + + -- Nivel + xpro.bd.salvar(tb_name, "lvl", 1) + + end + +end) + + +-- Callback ao adicionar XP +local callbacks_add_xp = {} +xpro.register_on_add_xp = function(func) + table.insert(callbacks_add_xp, func) +end + +-- Adicionar XP +xpro.add_xp = function(name, xp_add) + + -- Nome da tabela referente ao jogador no banco de dados + local tb_name = "jogador_"..name + + local xp_atual = xpro.get_player_xp(name) + + -- Evita salvar xp negativo + local new_xp = xp_atual+xp_add + if new_xp < 0 then + xpro.bd.salvar(tb_name, "xp", 0) + else + xpro.bd.salvar(tb_name, "xp", new_xp) + end + + -- Atualiza nivel + local old_lvl = xpro.get_player_lvl(name) + local new_level = get_lvl(new_xp) + xpro.bd.salvar(tb_name, "lvl", new_level) + + -- Executa callback registradas + for _,func in ipairs(callbacks_add_xp) do + func(name, xp_add, old_lvl ~= new_level) + end + +end + + +-- Callback ao remover XP +local callbacks_rem_xp = {} +xpro.register_on_rem_xp = function(func) + table.insert(callbacks_rem_xp, func) +end + +-- Remover XP +xpro.rem_xp = function(name, xp_rem) + + -- Nome da tabela referente ao jogador no banco de dados + local tb_name = "jogador_"..name + + local xp_atual = xpro.get_player_xp(name) + + -- Evita salvar xp negativo + local new_xp = xp_atual-xp_rem + if new_xp < 0 then + xpro.bd.salvar(tb_name, "xp", 0) + else + xpro.bd.salvar(tb_name, "xp", new_xp) + end + + -- Atualiza nivel + local old_lvl = xpro.get_player_lvl(name) + local new_level = get_lvl(new_xp) + xpro.bd.salvar(tb_name, "lvl", new_level) + + -- Executa callback registradas + for _,func in ipairs(callbacks_rem_xp) do + func(name, xp_rem, old_lvl ~= new_level) + end + +end + + + + + + + + diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..069f340 --- /dev/null +++ b/depends.txt @@ -0,0 +1,3 @@ +default +intllib? +sfinv? diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..d0b3211 --- /dev/null +++ b/description.txt @@ -0,0 +1,2 @@ + +Experiencia para jogadores | Experience for players diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3abcaac --- /dev/null +++ b/init.lua @@ -0,0 +1,44 @@ +--[[ + Mod Xpro 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 . + + Inicializador de variaveis e scripts + ]] + +-- Notificador de Inicializador +local notificar = function(msg) + if minetest.setting_get("log_mods") then + minetest.debug("[Xpro]"..msg) + end +end + +local modpath = minetest.get_modpath("xpro") + +-- Variavel global +xpro = {} + +-- Carregar scripts +notificar("Carregando scripts...") + +-- Criação do banco de dados +xpro.bd = dofile(modpath.."/lib/memor.lua") + +-- Variaveis personalizaveis +xpro.var = {} + +-- API +dofile(modpath.."/api.lua") +dofile(modpath.."/sfinv.lua") +dofile(modpath.."/progresso.lua") +dofile(modpath.."/ranking.lua") + +-- Metodos para evoluir +dofile(modpath.."/metodos/dig_node.lua") +dofile(modpath.."/metodos/place_node.lua") + +notificar("OK") + diff --git a/lib/intllib.lua b/lib/intllib.lua new file mode 100644 index 0000000..6669d72 --- /dev/null +++ b/lib/intllib.lua @@ -0,0 +1,45 @@ + +-- Fallback functions for when `intllib` is not installed. +-- Code released under Unlicense . + +-- Get the latest version of this file at: +-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua + +local function format(str, ...) + local args = { ... } + local function repl(escape, open, num, close) + if escape == "" then + local replacement = tostring(args[tonumber(num)]) + if open == "" then + replacement = replacement..close + end + return replacement + else + return "@"..open..num..close + end + end + return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl)) +end + +local gettext, ngettext +if minetest.get_modpath("intllib") then + if intllib.make_gettext_pair then + -- New method using gettext. + gettext, ngettext = intllib.make_gettext_pair() + else + -- Old method using text files. + gettext = intllib.Getter() + end +end + +-- Fill in missing functions. + +gettext = gettext or function(msgid, ...) + return format(msgid, ...) +end + +ngettext = ngettext or function(msgid, msgid_plural, n, ...) + return format(n==1 and msgid or msgid_plural, ...) +end + +return gettext, ngettext diff --git a/lib/memor.lua b/lib/memor.lua new file mode 100644 index 0000000..bee9823 --- /dev/null +++ b/lib/memor.lua @@ -0,0 +1,302 @@ +--[[ + Lib Memor para Minetest + Memor v1.3 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 . + + Inicializador de scripts + ]] + +local modname = minetest.get_current_modname() + +local modpath = minetest.get_modpath(modname) + +-- Variavel global +local memor = {} + +-- Rotinas de interação com arquivos + +-- Diretorio do mundo +local wpath = minetest.get_worldpath() + +-- Cria um diretório na pasta do mundo +function memor.mkdir(dir) + 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(dir, arquivo, dados, is_text) + + if dir == nil or arquivo == nil or dados == nil then + minetest.log("error", "[Memor] Faltou dados (em memor.escrever)") + return false + end + + if is_text ~= true then + dados = minetest.serialize(dados) + else + dados = string.format(dados) + end + if dados == "" then + minetest.log("error", "[Memor] Dado fornecido invalido (em memor.escrever)") + return false + end + local saida = io.open(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo, "w") + if saida then + saida:write(dados) + io.close(saida) + return true + end + -- Cria diretorio (tabela) caso nao exista + memor.mkdir(modname.."/"..dir) + saida = io.open(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo, "w") + if saida then + saida:write(dados) + io.close(saida) + return true + end + + minetest.log("error", "[Memor] Impossivel escrever dados em "..modname.."/"..dir.."/"..arquivo.." (em memor.escrever)") + return false +end + +-- Ler dados de um arquivo de memória (Carregar) +function memor.ler(dir, arquivo, is_text) + + if dir == nil or arquivo == nil then + minetest.log("error", "[Memor] Faltou dados (em memor.ler)") + return nil + end + + local entrada = io.open(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo, "r") + if entrada ~= nil then + local dados + if is_text ~= true then + dados = entrada:read("*l") + dados = minetest.deserialize(dados) + else + dados = entrada:read("*a") + dados = 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(dir, arquivo) + + if not dir or not arquivo then + minetest.log("error", "[Memor] Faltou dados (em memor.deletar)") + return false + end + + os.remove(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo) + return true +end + + +-- Deletar um diretório +function memor.deletar_dir(dir) + + if not dir then + minetest.log("error", "[Memor] Faltou dados (em memor.deletar_dir)") + return false + end + + local list = minetest.get_dir_list(wpath .. "/" .. modname .. "/" .. dir) + + for n, arquivo in ipairs(list) do + os.remove(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo) + end + + os.remove(wpath .. "/" .. modname .. "/" .. dir) + return true +end + +-- Fim + +-- Rotinas de consutas a arquivos + +-- Verifica diretorios e corrige +verificar = function(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 == modname then + r = true + break + end + end + -- Diretorio inexistente + if r == false then + memor.mkdir(modname) + end + + -- Verifica e corrige subdiretorio + local list = minetest.get_dir_list(minetest.get_worldpath().."/"..modname, true) + local 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(modname.."/"..subdir) + end + +end + + +-- Inserir dados +memor.inserir = function(tb, index, valor, is_text) + + -- Tenta inserir direto + if memor.escrever(tb, index, valor, is_text) == true then return true end + + verificar(tb) + + if memor.escrever(tb, index, valor, is_text) then + return true + else + minetest.log("error", "[Memor] Impossivel salvar dados (em memor.inserir)") + return false + end + +end + + +-- Ler dados +memor.consultar = function(tb, index, is_text) + + local r = memor.ler(tb, index, is_text) + if r == nil then + local mod = modname + 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(subdir, arquivo) + + local dir = modname + + local list = minetest.get_dir_list(wpath .. "/" .. dir .. "/" .. subdir) + local 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(subdir) + + local dir = modname + + 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 + +-- Fim + +-- Montagem de banco de dados + +bd = {} + +-- Inserir dados comuns +bd.salvar = function(tb, index, valor) + return memor.inserir(tb, index, valor) +end + +-- Inserir textos complexos +bd.salvar_texto = function(tb, index, valor) + return memor.inserir(tb, index, valor, true) +end + +-- Consultar dados +bd.pegar = function(tb, index) + return memor.consultar(tb, index) +end + +-- Inserir dados +bd.pegar_texto = function(tb, index, valor) + return memor.consultar(tb, index, true) +end + +-- Verificar dados +bd.verif = function(tb, index) + return memor.verificar(tb, index) +end + +-- Remover dados +bd.remover = function(tb, index) + return memor.deletar(tb, index) +end + +-- Remover tabela +bd.drop_tb = function(tb) + return memor.deletar_dir(tb) +end + +-- Listar dados +bd.listar = function(tb) + return memor.listar(tb) +end + +return bd + +-- Fim diff --git a/locale/Arquivos para traduzir.txt b/locale/Arquivos para traduzir.txt new file mode 100644 index 0000000..eb7ef1c --- /dev/null +++ b/locale/Arquivos para traduzir.txt @@ -0,0 +1 @@ +autogen.lua balao.lua balao_decor.lua bau.lua bau_spawn.lua check_balao_proprio.lua comandos.lua compatibilidade.lua comum.lua corda.lua gerar_balao_aleatorio.lua interface_bau.lua interface_jogador.lua ir_balao.lua online.lua reivindicar.lua reparar_balao.lua visitas.lua mensagens.lua diff --git a/locale/en.po~ b/locale/en.po~ new file mode 100644 index 0000000..3dc16d4 --- /dev/null +++ b/locale/en.po~ @@ -0,0 +1,238 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-13 00:49-0300\n" +"PO-Revision-Date: 2018-07-13 00:59-0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.6\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: balao.lua balao_decor.lua +msgid "Balao Decorativo" +msgstr "Decorative Balloon" + +#: balao_decor.lua +msgid "Node de Balao Decorativo" +msgstr "Decorative Balloon Node" + +#: bau.lua +msgid "Bau do Balao" +msgstr "Balloon Box" + +#: bau.lua +msgid "Esse Balao nao lhe pertence" +msgstr "This Balloon is not yours" + +#: bau_spawn.lua +msgid "Bau do Balao do Centro" +msgstr "Balloon Box of Center Spawn" + +#: bau_spawn.lua +msgid "Novo centro definido" +msgstr "New spawn center defined" + +#: bau_spawn.lua +msgid "Precisa do privilegio 'server' para colocar esse bau" +msgstr "Need the 'server' privilege to put this Balloon Box" + +#: corda.lua +msgid "Corda de Balao" +msgstr "Balloon Rope" + +#: gerar_balao_aleatorio.lua +msgid "Novo local encontrado" +msgstr "New place found" + +#: interface_bau.lua +msgid "Muito distante do seu Bau de Balao" +msgstr "Far away from your Balloon Box" + +#: interface_bau.lua +msgid "Ir para Centro" +msgstr "Go to Center" + +#: interface_bau.lua +msgid "Reparar Balao" +msgstr "Repair Balloon" + +#: interface_bau.lua visitas.lua +msgid "Receber seguidor" +msgstr "Receive follower" + +#: interface_bau.lua +msgid "Ir para seu Balao" +msgstr "Go to your balloon" + +#: interface_bau.lua visitas.lua +msgid "Seguir jogador" +msgstr "Follow a player" + +#: interface_bau.lua +msgid "Precisas ter um balao ativo" +msgstr "You need to have an active balloon" + +#: interface_bau.lua mensagens.lua +msgid "Viagem ao Centro realizada" +msgstr "Journey to the Center held" + +#: interface_bau.lua +msgid "Balao ativo" +msgstr "Balloon is active" + +#: interface_jogador.lua +msgid "Gerar Balao" +msgstr "Generate a Balloon" + +#: interface_jogador.lua +msgid "Por Balao Aqui" +msgstr "Place Balloon here" + +#: ir_balao.lua +msgid "Sem nenhum balao ainda" +msgstr "No balloon yet" + +#: ir_balao.lua +msgid "Seu balao foi destruido" +msgstr "Your balloon has been destroyed" + +#: ir_balao.lua +msgid "Viagem para o posto de seu balao realizada" +msgstr "Trip to the post of your balloon was held" + +#: reivindicar.lua +msgid "Balao reivindicado com sucesso" +msgstr "Balloon successfully claimed" + +#: reparar_balao.lua +msgid "O caminho para cima esta obstruido (corda) portanto abra mais o local" +msgstr "The way up is obstructed (rope) so open the place further" + +#: reparar_balao.lua +msgid "" +"Parte de cima obstruida (onde fica o balao) portanto libere o local ou suba" +msgstr "" +"Top is obstructed (where the balloon is) so wipe the top or go to a highest " +"location" + +#: visitas.lua +msgid "Pedidos recebidos" +msgstr "Requests received" + +#: visitas.lua +msgid "Voltar" +msgstr "Return" + +#: visitas.lua +msgid "Enviar pedido" +msgstr "Send request" + +#: visitas.lua +msgid "Nao podes seguir a si mesmo" +msgstr "You can not follow yourself" + +#: visitas.lua +msgid "@1 offline ou inexistente" +msgstr "@1 offline or nonexistent" + +#: visitas.lua +msgid "Pedido enviado a @1 ... Agora precisa pedir para aceitar seu pedido" +msgstr "" +"Request sent to @1 ... Now you need to advise him to accept your request" + +#: visitas.lua +msgid "Pedido invalido" +msgstr "Invalid request" + +#: visitas.lua +msgid "@1 offline" +msgstr "@1 offline" + +#: visitas.lua +msgid "@1 saiu de perto do balao do centro" +msgstr "@1 left close to the center balloon" + +#: visitas.lua +msgid "Seu pedido para seguir @1 foi aceito mas voce se afastou do balao" +msgstr "" +"Your request to follow @1 was accepted but you walked away from the balloon" + +#: visitas.lua +msgid "@1 te seguiu" +msgstr "@1 followed you" + +#: visitas.lua +msgid "Voce seguiu @1" +msgstr "You followed @1" + +#: mensagens.lua +msgid "" +"Nao pode gerar um novo balao ainda (sao necessarias 24 horas desde a ultima " +"vez que gerou)" +msgstr "" +"It can not generate a new balloon yet (it is necessary 24 hours since the " +"last time it generated)" + +#: mensagens.lua +msgid "Aguarde alguns segundos enquanto o balao esta endo preparado" +msgstr "Wait a few seconds while the balloon is being prepared" + +#: mensagens.lua +msgid "O Seu Balao ficou inoperante" +msgstr "Your Balloon was inoperative" + +#: mensagens.lua +msgid "Muito distante do Bau de Balao do Centro" +msgstr "Far away from the Balloon Box of Spawn Center." + +#: mensagens.lua +msgid "Muito distante do seu proprio Bau de Balao" +msgstr "Far away from the your Balloon Box" + +#: mensagens.lua +msgid "" +"Mantenha o local limpo e aberto para levantar que o balao seja levantado " +"automaticamente" +msgstr "" +"Keep the place clean and open to raise the balloon to be lifted automatically" + +#: mensagens.lua +msgid "Viagem para seu proprio balao realizada" +msgstr "Travel to your own balloon held" + +#: mensagens.lua +msgid "Precisa subir para um local mais alto" +msgstr "You need to climb to a higher location" + +#: mensagens.lua +msgid "Precisa estar num lugar mais aberto" +msgstr "You need to be in a cleaner and more open place" + +#: mensagens.lua +msgid "Objetos obstruem a parte de cima portanto libere o local ou suba" +msgstr "Objects obstruct the top so remove the objects and try again" + +#~ msgid "" +#~ "Objetos obstruem a parte de cima portanto remova os objetos e tente " +#~ "novamente" +#~ msgstr "Objects obstruct the top so remove the objects and try again" + +#~ msgid "Precisa estar em local aberto" +#~ msgstr "It needs to be in a clean and open place" + +#~ msgid "" +#~ "Nao pode gerar um novo balao ainda. (sao necessarias 24 horas desde a " +#~ "ultima vez que gerou)" +#~ msgstr "" +#~ "Can not generate a new balloon yet. (it is necessary 24 hours since the " +#~ "last time it generated)" diff --git a/locale/pt.po~ b/locale/pt.po~ new file mode 100644 index 0000000..02b0cb2 --- /dev/null +++ b/locale/pt.po~ @@ -0,0 +1,269 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-13 00:49-0300\n" +"PO-Revision-Date: 2018-07-13 00:45-0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.6\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: balao.lua balao_decor.lua +msgid "Balao Decorativo" +msgstr "Balao Decorativo" + +#: balao_decor.lua +msgid "Node de Balao Decorativo" +msgstr "Node de Balao Decorativo" + +#: bau.lua +msgid "Bau do Balao" +msgstr "Bau do Balao" + +#: bau.lua +msgid "Esse Balao nao lhe pertence" +msgstr "Esse Balao nao lhe pertence" + +#: bau_spawn.lua +msgid "Bau do Balao do Centro" +msgstr "Bau do Balao do Centro" + +#: bau_spawn.lua +msgid "Novo centro definido" +msgstr "Novo centro definido" + +#: bau_spawn.lua +msgid "Precisa do privilegio 'server' para colocar esse bau" +msgstr "Precisa do privilegio 'server' para colocar esse bau" + +#: corda.lua +msgid "Corda de Balao" +msgstr "Corda de Balao" + +#: gerar_balao_aleatorio.lua +msgid "Novo local encontrado" +msgstr "Novo local encontrado" + +#: interface_bau.lua +msgid "Muito distante do seu Bau de Balao" +msgstr "Muito distante do seu Bau de Balao" + +#: interface_bau.lua +msgid "Ir para Centro" +msgstr "Ir para Centro" + +#: interface_bau.lua +msgid "Reparar Balao" +msgstr "Reparar Balao" + +#: interface_bau.lua visitas.lua +msgid "Receber seguidor" +msgstr "Receber seguidor" + +#: interface_bau.lua +msgid "Ir para seu Balao" +msgstr "Ir para seu Balao" + +#: interface_bau.lua visitas.lua +msgid "Seguir jogador" +msgstr "Seguir jogador" + +#: interface_bau.lua +msgid "Precisas ter um balao ativo" +msgstr "Precisas ter um balao ativo" + +#: interface_bau.lua mensagens.lua +msgid "Viagem ao Centro realizada" +msgstr "Viagem ao Centro realizada" + +#: interface_bau.lua +msgid "Balao ativo" +msgstr "Balao ativo" + +#: interface_jogador.lua +msgid "Gerar Balao" +msgstr "Gerar Balao" + +#: interface_jogador.lua +msgid "Por Balao Aqui" +msgstr "Por Balao Aqui" + +#: ir_balao.lua +msgid "Sem nenhum balao ainda" +msgstr "Sem nenhum balao ainda" + +#: ir_balao.lua +msgid "Seu balao foi destruido" +msgstr "Seu balao foi destruido" + +#: ir_balao.lua +msgid "Viagem para o posto de seu balao realizada" +msgstr "Viagem para o posto de seu balao realizada" + +#: reivindicar.lua +msgid "Balao reivindicado com sucesso" +msgstr "Balao reivindicado com sucesso" + +#: reparar_balao.lua +msgid "O caminho para cima esta obstruido (corda) portanto abra mais o local" +msgstr "O caminho para cima esta obstruido (corda) portanto abra mais o local" + +#: reparar_balao.lua +msgid "" +"Parte de cima obstruida (onde fica o balao) portanto libere o local ou suba" +msgstr "" +"Parte de cima obstruida (onde fica o balao) portanto libere o local ou suba" + +#: visitas.lua +msgid "Pedidos recebidos" +msgstr "Pedidos recebidos" + +#: visitas.lua +msgid "Voltar" +msgstr "Voltar" + +#: visitas.lua +msgid "Enviar pedido" +msgstr "Enviar pedido" + +#: visitas.lua +msgid "Nao podes seguir a si mesmo" +msgstr "Nao podes seguir a si mesmo" + +#: visitas.lua +msgid "@1 offline ou inexistente" +msgstr "@1 offline ou inexistente" + +#: visitas.lua +msgid "Pedido enviado a @1 ... Agora precisa pedir para aceitar seu pedido" +msgstr "Pedido enviado a @1 ... Agora precisa pedir para aceitar seu pedido" + +#: visitas.lua +msgid "Pedido invalido" +msgstr "Pedido invalido" + +#: visitas.lua +msgid "@1 offline" +msgstr "@1 offline" + +#: visitas.lua +msgid "@1 saiu de perto do balao do centro" +msgstr "@1 saiu de perto do balao do centro" + +#: visitas.lua +msgid "Seu pedido para seguir @1 foi aceito mas voce se afastou do balao" +msgstr "Seu pedido para seguir @1 foi aceito mas voce se afastou do balao" + +#: visitas.lua +msgid "@1 te seguiu" +msgstr "@1 te seguiu" + +#: visitas.lua +msgid "Voce seguiu @1" +msgstr "Voce seguiu @1" + +#: mensagens.lua +msgid "" +"Nao pode gerar um novo balao ainda (sao necessarias 24 horas desde a ultima " +"vez que gerou)" +msgstr "" +"Nao pode gerar um novo balao ainda (sao necessarias 24 horas desde a ultima " +"vez que gerou)" + +#: mensagens.lua +msgid "Aguarde alguns segundos enquanto o balao esta endo preparado" +msgstr "Aguarde alguns segundos enquanto o balao esta endo preparado" + +#: mensagens.lua +msgid "O Seu Balao ficou inoperante" +msgstr "O Seu Balao ficou inoperante" + +#: mensagens.lua +msgid "Muito distante do Bau de Balao do Centro" +msgstr "Muito distante do Bau de Balao do Centro" + +#: mensagens.lua +msgid "Muito distante do seu proprio Bau de Balao" +msgstr "Muito distante do seu proprio Bau de Balao" + +#: mensagens.lua +msgid "" +"Mantenha o local limpo e aberto para levantar que o balao seja levantado " +"automaticamente" +msgstr "" +"Mantenha o local limpo e aberto para levantar que o balao seja levantado " +"automaticamente" + +#: mensagens.lua +msgid "Viagem para seu proprio balao realizada" +msgstr "Viagem para seu proprio balao realizada" + +#: mensagens.lua +msgid "Precisa subir para um local mais alto" +msgstr "Precisa subir para um local mais alto" + +#: mensagens.lua +msgid "Precisa estar num lugar mais aberto" +msgstr "Precisa estar num lugar mais aberto" + +#: mensagens.lua +msgid "Objetos obstruem a parte de cima portanto libere o local ou suba" +msgstr "Objetos obstruem a parte de cima portanto libere o local ou suba" + +#~ msgid "" +#~ "Objetos obstruem a parte de cima portanto remova os objetos e tente " +#~ "novamente" +#~ msgstr "" +#~ "Objetos obstruem a parte de cima portanto remova os objetos e tente " +#~ "novamente" + +#~ msgid "Precisa estar em local aberto" +#~ msgstr "Precisa estar em local aberto" + +#~ msgid "" +#~ "Nao pode gerar um novo balao ainda. (sao necessarias 24 horas desde a " +#~ "ultima vez que gerou)" +#~ msgstr "" +#~ "Nao pode gerar um novo balao ainda. (sao necessarias 24 horas desde a " +#~ "ultima vez que gerou)" + +#~ msgid "" +#~ "O caminho para cima esta obstruido. Encontre um lugar onde de para o " +#~ "balao descer" +#~ msgstr "" +#~ "O caminho para cima esta obstruido. Encontre um lugar onde de para o " +#~ "balao descer" + +#~ msgid "Parte de cima obstruida. Libere o local ou suba" +#~ msgstr "Parte de cima obstruida. Libere o local ou suba" + +#~ msgid "" +#~ "Balao inoperante. Aguarde mantenha o local limpo e aberto e aguarde ele " +#~ "ficar pronto" +#~ msgstr "" +#~ "Balao inoperante. Aguarde mantenha o local limpo e aberto e aguarde ele " +#~ "ficar pronto" + +#~ msgid "O Balao ja esta ativo. Nao precisa reparar" +#~ msgstr "O Balao ja esta ativo. Nao precisa reparar" + +#~ msgid "O Seu Balao nao esta funcionando. O local foi destruido ou obstruido" +#~ msgstr "" +#~ "O Seu Balao nao esta funcionando. O local foi destruido ou obstruido" + +#~ msgid "" +#~ "Nao pode colocar um novo balao ainda. (sao necessarias 24 horas desde a " +#~ "ultima vez que gerou ou colocou)" +#~ msgstr "" +#~ "Nao pode colocar um novo balao ainda. (sao necessarias 24 horas desde a " +#~ "ultima vez que gerou ou colocou)" diff --git a/metodos/dig_node.lua b/metodos/dig_node.lua new file mode 100644 index 0000000..514e693 --- /dev/null +++ b/metodos/dig_node.lua @@ -0,0 +1,28 @@ +--[[ + Mod Xpro 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 . + + Evoluir ao cavar um node + ]] + + +minetest.register_on_dignode(function(pos, oldnode, digger) + + xpro.add_xp(digger:get_player_name(), 30) + +end) + + + + + + + + + + + diff --git a/metodos/place_node.lua b/metodos/place_node.lua new file mode 100644 index 0000000..d51dc48 --- /dev/null +++ b/metodos/place_node.lua @@ -0,0 +1,27 @@ +--[[ + Mod Xpro 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 . + + Evoluir ao colocar um node + ]] + +minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) + + xpro.rem_xp(placer:get_player_name(), 30) + +end) + + + + + + + + + + + diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..ad750a9 --- /dev/null +++ b/mod.conf @@ -0,0 +1 @@ +name = xpro diff --git a/progresso.lua b/progresso.lua new file mode 100644 index 0000000..902a339 --- /dev/null +++ b/progresso.lua @@ -0,0 +1,34 @@ +--[[ + Mod Xpro 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 . + + Ao evoluir ou regradir niveis + ]] + + +xpro.register_on_add_xp(function(name, xp_added, lvl_changed) + if lvl_changed == true then + minetest.chat_send_player(name, "Atingiu Nivel "..xpro.get_player_lvl(name)) + end +end) + + +xpro.register_on_rem_xp(function(name, xp_removed, lvl_changed) + if lvl_changed == true then + minetest.chat_send_player(name, "Regrediu ao Nivel "..xpro.get_player_lvl(name)) + end +end) + + + + + + + + + + diff --git a/ranking.lua b/ranking.lua new file mode 100644 index 0000000..b1d9251 --- /dev/null +++ b/ranking.lua @@ -0,0 +1,132 @@ +--[[ + Mod Xpro 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 . + + Gerenciamento do Ranking + ]] + +-- Pegar ranking +xpro.get_rank = function() + return xpro.bd.pegar("ranking", "pontos") +end + +-- Tabela de acesso rapido ao ranking global +xpro.ranking = {} + +-- Atualizar ranking +xpro.update_rank = function(name) + local rank = xpro.get_rank() + local pontos = xpro.bd.pegar("jogador_"..name, "xp") + local m1 = {name=name,pontos=pontos} + local m2 = {} + for x=1, 10 do + -- Se o objeto atual for o novo colocado + if m1.name == name then + -- Verifica se fica no lugar + if rank[tostring(x)].pontos < m1.pontos then + + --Substitui posicao + m2.name = rank[tostring(x)].name + m2.pontos = rank[tostring(x)].pontos + rank[tostring(x)].name = m1.name + rank[tostring(x)].pontos = m1.pontos + + -- Verifica se o que foi tirado é ele mesmo + if name == m2.name then + break + end + + -- m2 para a ser m1 para a proxima comparacao + m1.name = m2.name + m1.pontos = m2.pontos + + -- Nao é maior mas é o mesmo jogador + elseif m1.name == rank[tostring(x)].name then + -- atualiza os pontos e encerra + rank[tostring(x)].pontos = m1.pontos + break + end + + -- Se o objeto atual for um recolocado + else + -- Se for o objeto novo que ja foi colocado + if rank[tostring(x)].name == name then + rank[tostring(x)].name = m1.name + rank[tostring(x)].pontos = m1.pontos + break + + -- Se nao for compara normalmente + else + if rank[tostring(x)].pontos < m1.pontos then + -- Substitui posicao + m2.name = rank[tostring(x)].name + m2.pontos = rank[tostring(x)].pontos + rank[tostring(x)].name = m1.name + rank[tostring(x)].pontos = m1.pontos + + -- m2 para a ser m1 para a proxima comparacao + m1.name = m2.name + m1.pontos = m2.pontos + end + end + + end + end + xpro.bd.salvar("ranking", "pontos", rank) + xpro.ranking = minetest.deserialize(minetest.serialize(rank)) +end + +-- Certifica de que rank existe +if xpro.bd.verif("ranking", "pontos") == false then + rank = { + ["1"] = {name="-1-",pontos=0}, + ["2"] = {name="-2-",pontos=0}, + ["3"] = {name="-3-",pontos=0}, + ["4"] = {name="-4-",pontos=0}, + ["5"] = {name="-5-",pontos=0}, + ["6"] = {name="-6-",pontos=0}, + ["7"] = {name="-7-",pontos=0}, + ["8"] = {name="-8-",pontos=0}, + ["9"] = {name="-9-",pontos=0}, + ["10"] = {name="-10-",pontos=0}, + } + xpro.bd.salvar("ranking", "pontos", rank) +end + +-- Formspec do ranking +xpro.ranking_formspec = "" + +local update_formspec = function() + + xpro.ranking_formspec = "size[7,6]" + ..default.gui_bg + ..default.gui_bg_img + .."label[0.6,0.4;Pontos]" + .."label[2.1,0.4;Jogador]" + + -- Monta Ranking + local rank = xpro.get_rank() + for x=1, 10 do + local w = (0.4+(0.5*x)) + xpro.ranking_formspec = xpro.ranking_formspec .."label[0.6,"..w..";"..rank[tostring(x)].pontos.."]" + .."label[2.1,"..w..";"..rank[tostring(x)].name.."]" + end +end +update_formspec() + +xpro.register_on_add_xp(function(name, xp_added) + --if xpro.ranking + xpro.update_rank(name) + update_formspec() +end) +xpro.register_on_rem_xp(function(name, xp_removed) + xpro.update_rank(name) + update_formspec(name) +end) + + + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..925dafc Binary files /dev/null and b/screenshot.png differ diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..6875b28 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,22 @@ +# Configurações aplicaveis para o menu gráfico + +#Gera automaticamente um balao proprio para jogadores +#que ainda nunca geraram +#Automatically generates a balloon for players who +#have never yet generated it +telepro_autogen (Autogerar Balao proprio) bool true + +#Limita a geração de balões proprios em lugares aleatorios do mapa +#Limite de 1 a cada 24 horas +#Limits the generation of own balloons in random places on the map +#Limit of 24 hours for a new generation +telepro_daily_limit (Limite diario para gerar) bool true + +#Tempo entre cada vez que o balão do jogador é verificado +#Time step which balloon is verified +telepro_time_check_balloon (Tempo do iterador de checagem do balao) int 15 5 + + + + + diff --git a/sfinv.lua b/sfinv.lua new file mode 100644 index 0000000..bad1729 --- /dev/null +++ b/sfinv.lua @@ -0,0 +1,60 @@ +--[[ + Mod Xpro 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 . + + Inventario sfinv + ]] + +if sfinv == nil then return end + +local S = xpro.S + +sfinv.register_page("xpro:info", { + title = "Nivel", + + get = function(self, player, context) + + local name = player:get_player_name() + + local my_xp = xpro.get_player_xp(name) + local my_lvl = xpro.get_player_lvl(name) + + local formspec = "label[0,0;Nivel "..my_lvl.."]" + .."label[0,0.5;Pontos: "..my_xp.."]" + .."button[4,0;4,1;ranking;Ranking Global]" + + return sfinv.make_formspec(player, context, formspec, true) + end, + on_player_receive_fields = function(self, player, context, fields) + if fields.ranking then + minetest.show_formspec(player:get_player_name(), "xpro:ranking", xpro.ranking_formspec) + end + end, + + +}) + +-- Atualização do painel ao adicionar ou remover pontos +xpro.register_on_add_xp(function(name, xp_added) + sfinv.set_player_inventory_formspec(minetest.get_player_by_name(name)) +end) +xpro.register_on_rem_xp(function(name, xp_removed) + sfinv.set_player_inventory_formspec(minetest.get_player_by_name(name)) +end) + + + + + + + + + + + + + diff --git a/tools/xgettext.bat b/tools/xgettext.bat new file mode 100644 index 0000000..18403db --- /dev/null +++ b/tools/xgettext.bat @@ -0,0 +1,33 @@ +@echo off +setlocal + +set me=%~n0 + +rem # Uncomment the following line if gettext is not in your PATH. +rem # Value must be absolute and end in a backslash. +rem set gtprefix=C:\path\to\gettext\bin\ + +if "%1" == "" ( + echo Usage: %me% FILE... 1>&2 + exit 1 +) + +set xgettext=%gtprefix%xgettext.exe +set msgmerge=%gtprefix%msgmerge.exe + +md locale > nul 2>&1 +echo Generating template... 1>&2 +echo %xgettext% --from-code=UTF-8 -kS -kNS:1,2 -k_ -o locale/template.pot %* +%xgettext% --from-code=UTF-8 -kS -kNS:1,2 -k_ -o locale/template.pot %* +if %ERRORLEVEL% neq 0 goto done + +cd locale + +for %%f in (*.po) do ( + echo Updating %%f... 1>&2 + %msgmerge% --update %%f template.pot +) + +echo DONE! 1>&2 + +:done diff --git a/tools/xgettext.sh b/tools/xgettext.sh new file mode 100755 index 0000000..1504f42 --- /dev/null +++ b/tools/xgettext.sh @@ -0,0 +1,27 @@ +#! /bin/bash + +me=$(basename "${BASH_SOURCE[0]}"); + +if [[ $# -lt 1 ]]; then + echo "Usage: $me FILE..." >&2; + exit 1; +fi + +mkdir -p locale; +echo "Generating template..." >&2; +xgettext --from-code=UTF-8 \ + --keyword=S \ + --keyword=NS:1,2 \ + --keyword=N_ \ + --add-comments='Translators:' \ + --add-location=file \ + -o locale/template.pot \ + "$@" \ + || exit; + +find locale -name '*.po' -type f | while read -r file; do + echo "Updating $file..." >&2; + msgmerge --update "$file" locale/template.pot; +done + +echo "DONE!" >&2; diff --git a/tradutor.lua b/tradutor.lua new file mode 100644 index 0000000..f9b207a --- /dev/null +++ b/tradutor.lua @@ -0,0 +1,183 @@ +--[[ + Mod xpro 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 . + + Sistema de tradução + ]] + +-- Modpath +local modpath = minetest.get_modpath("xpro") + +-- Tradução intllib +xpro.intllib = {} +xpro.intllib.S, xpro.intllib.NS = dofile(modpath.."/lib/intllib.lua") + +-- Configura tradutor opicional +xpro.S = xpro.intllib.S +xpro.NS = xpro.intllib.NS + +-- +-- Ajustes devido ao bug de tradutor ler apenas traduzir do ingles +-- + +-- Strings para repassar textos em ingles +local pt_to_en = {} + +-- Gera arquivos de tradução xpro.*.tr +do + local file_to_tb = function(file) + local msgid = nil + local msgstr = nil + local tb = {} + for line in io.lines(file) do + + -- Iniciando 'msgid' + if string.sub(line, 1, 5) == "msgid" then + + -- Escrever no catalogo a anterior + if msgid ~= nil and msgstr ~= nil then + if msgid ~= "" then + tb[msgid] = msgstr + end + msgid = nil + msgstr = nil + end + + if line == "msgid \"\"" then + msgid = "" + else + msgid = string.sub(line, 8, (string.len(line)-1)) + end + + -- Continuando 'msgid' + elseif string.sub(line, 1, 1) == "\"" and msgstr == nil and msgid ~= nil then + msgid = msgid .. string.sub(line, 2, (string.len(line)-1)) + + -- Iniciando 'msgstr' + elseif string.sub(line, 1, 6) == "msgstr" then + + if line == "msgstr \"\"" then + msgstr = "" + else + msgstr = string.sub(line, 9, (string.len(line)-1)) + end + + -- Continuando 'msgstr' + elseif string.sub(line, 1, 1) == "\"" and msgstr ~= nil then + msgstr = msgstr .. string.sub(line, 2, (string.len(line)-1)) + + end + + + end + + -- Escrever ultima + if msgid ~= nil and msgstr ~= nil then + if msgid ~= "" then + tb[msgid] = msgstr + end + msgid = nil + msgstr = nil + end + + return tb + end + + -- Pegar strings principais en-pt para realizar as trocas + pt_to_en = file_to_tb(modpath.."/locale/en.po") + + --minetest.log("error", "pt_to_en = "..dump(pt_to_en)) + + local list = minetest.get_dir_list(modpath.."/locale") + for _,file in ipairs(list) do + + if string.match(file, "~") == nil then + + -- Traduções ".po" + if string.match(file, ".pot") == nil and string.match(file, ".po") then + + local lang_code = string.gsub(file, ".po", "") + + local pt_to_lang = file_to_tb(modpath.."/locale/"..file) + + -- tabela desejada + local en_to_lang = {} + for pt,en in pairs(pt_to_en) do + en_to_lang[en] = pt_to_lang[pt] + end + + -- Novo arquivo + local new_file = "### Arquivo gerado por xpro apartir de "..file.."\n# textdomain: xpro\n" + for en,lang in pairs(en_to_lang) do + new_file = new_file .. en .. "=" .. lang .. "\n" + end + local saida = io.open(modpath.."/locale/xpro."..lang_code..".tr", "w") + saida:write(new_file) + io.close(saida) + + -- Gera arquivo com lang_code nulo para evitar mensagens de erro (bug do minetest) + if lang_code == "en" then + local saida2 = io.open(modpath.."/locale/xpro..tr", "w") + saida2:write(new_file) + io.close(saida2) + end + end + end + end +end + +-- Ajuste para repassar termos em ingles +local s +if minetest.get_translator ~= nil then + s = minetest.get_translator("xpro") +else + s = xpro.intllib.S +end + +xpro.s = function(...) + local args = { ... } + if pt_to_en[args[1]] ~= nil then + return s(pt_to_en[args[1]], unpack(args, 2)) + end + minetest.log("error", "[xpro] String "..dump(args[1]).." nao catalogada") + return s(...) +end + +-- Não troca string caso esteja trabalhando com intllib +if minetest.get_modpath("intllib") ~= nil + and minetest.get_translator == nil +then + xpro.s = s +end + +xpro.S = function(...) + local args = { ... } + if type(args[1]) == "table" then + local r = {} + for n,a in ipairs(args[1]) do + if n ~= 1 then -- Não traduz o primeiro + table.insert(r, xpro.S(a)) + else + table.insert(r, a) + end + end + + return xpro.s(unpack(r)) + + elseif type(args[1]) == "string" then + -- Não traduz caso faltem argumentos (devido strings ilustrativas) + return xpro.s(...) + + else + return args[1] + end +end + +-- Função que retorna a string inalterada para passar pela checagem +xpro.Sfake = function(s) return s end + +