Testing a new xp+levels mod

master
Solebull 2018-12-29 15:54:51 +01:00
parent d9dbaa4615
commit 92533a19fc
54 changed files with 3536 additions and 1 deletions

View File

@ -144,6 +144,7 @@ It's really fast. May be used on a website, to show the actual map.
**** pvp shoudld be a privillege
- So we can revoke it to some players
**** TODO Continue to test factions and NPC mod
CLOCK: [2018-12-29 sam. 05:31]--[2018-12-29 sam. 06:24] => 0:53
CLOCK: [2018-12-29 sam. 01:34]--[2018-12-29 sam. 01:57] => 0:23
CLOCK: [2018-12-24 lun. 01:04]--[2018-12-24 lun. 01:12] => 0:08
CLOCK: [2018-12-24 lun. 00:51]--[2018-12-24 lun. 00:52] => 0:01
@ -197,7 +198,6 @@ It's really fast. May be used on a website, to show the actual map.
Try to add them as protected chest
- [ ] We can't open doors when created by another player
Maybe completely remove doors/ mod
- [ ] Faction chest must be for faction only (no parcel needed)
- [ ] Try to find a protector mod, test it
@ -224,6 +224,11 @@ It's really fast. May be used on a website, to show the actual map.
[mg_villages] ERROR: Did not find a suitable replacement for cottages:barrel (suggested but inexistant: cottages:barrel). Building: chateau_without_garden.
**** Try mumble-link
- see https://github.com/chipgw/minetest-mumble-wrapper
**** [feature_Levels] Try an XP+levels mod
- [ ] Trying to find a XP and level mod
But we can buy some things with that etc.
Doesn't show total level ?
But the ranking thing is really cool. Could use the same trick for Factions!
**** DONE Install and configure a mumble server
CLOCK: [2018-12-23 dim. 11:22]--[2018-12-23 dim. 11:43] => 0:21
CLOCK: [2018-12-23 dim. 10:12]--[2018-12-23 dim. 11:12] => 1:00

24
mods/xpro/API.txt Normal file
View File

@ -0,0 +1,24 @@
API para mod XPro v1.1.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
* `xpro.registrar_premio(name, Definições do Prêmio)`: Registra um premio para ser trocado por cash xp
* `name` é o nome de exibição do item na lista de prêmios
* Definições de Prêmio
{
item=<itemstring>, -- Item string do item a ser dado ao jogador
qtd=<number of itens>, -- Quantidade de itens a ser dado ao jogador
custo=<cost in xp cash>, -- Custo da troca em cash xp que o jogador vai ter que pagar
}
* `xpro.register_on_craft(name, xp)`: Registra um item para alterar xp ao craftar um item
* `xpro.register_on_dignode(name, xp)`: Registra um item para alterar xp ao cavar um node
* `xpro.register_on_placenode(name, xp)`: Registra um item para alterar xp ao colocar um node

165
mods/xpro/LICENSE Normal file
View File

@ -0,0 +1,165 @@
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.

26
mods/xpro/README.md Normal file
View File

@ -0,0 +1,26 @@
# 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/viewtopic.php?f=9&t=20499&p=325793#p325793)
[![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 <borgesdossantosbruno@gmail.com> (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 <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)

175
mods/xpro/api.lua Normal file
View File

@ -0,0 +1,175 @@
--[[
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 <http://www.gnu.org/licenses/>.
API
]]
-- Niveis de acoordo com XP
xpro.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
9200, -- Nivel 18
10500, -- Nivel 19
11900, -- Nivel 20
13400, -- Nivel 21
15000, -- Nivel 22
16700, -- Nivel 23
18500, -- Nivel 24
20400, -- Nivel 25
22400, -- Nivel 26
24500, -- Nivel 27
26700, -- Nivel 28
29000, -- Nivel 29
31400, -- Nivel 30
33900, -- Nivel 31
36500, -- Nivel 32
39200, -- Nivel 33
42000, -- Nivel 34
44900, -- Nivel 35
47900, -- Nivel 36
51000, -- Nivel 37
54200, -- Nivel 38
57500, -- Nivel 39
}
local tb_niveis = xpro.niveis
-- 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

15
mods/xpro/bower.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "xpro",
"description": "API de n\u00edveis e experiencia aos jogadores",
"keywords": [
"xpro"
],
"homepage": "https://github.com/BrunoMine/xpro",
"forum": "https://forum.minetest.net/viewtopic.php?t=1",
"screenshots": [
"https://raw.githubusercontent.com/BrunoMine/xpro/master/screenshot.png"
],
"authors": [
"BrunoMine"
]
}

8
mods/xpro/depends.txt Normal file
View File

@ -0,0 +1,8 @@
default
intllib?
sfinv?
hudbars?
beds?
farming?
wool?
carts?

View File

@ -0,0 +1,2 @@
Experiencia para jogadores | Experience for players

255
mods/xpro/hud.lua Normal file
View File

@ -0,0 +1,255 @@
--[[
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 <http://www.gnu.org/licenses/>.
Hud de XP e nivel
]]
local S = xpro.S
-- Mod Hudbars
if hb then
local get_progress = function(my_xp, my_lvl)
if xpro.niveis[my_lvl+1] == nil then return 100 end
local xp = xpro.niveis[my_lvl] - my_xp
local xp_t = xpro.niveis[my_lvl] - xpro.niveis[my_lvl+1]
local p = xp/xp_t
local r = math.ceil(p*100)
if r == 100 and (p*100) < 100 then r = 99 end
return r
end
-- Atualizar barra
local update_hb = function(name)
local player = minetest.get_player_by_name(name)
local my_xp = xpro.get_player_xp(name)
local my_lvl = xpro.get_player_lvl(name)
hb.change_hudbar(
-- player
player,
-- identifier
"xpro:xp",
-- new_value
get_progress(my_xp, my_lvl)
-- new_max_value
--nil,
-- new_icon
--"xpro_xp_icon.png",
-- new_bgicon
--"xpro_xp_bar_bgicon.png",
-- new_bar
--"xpro_xp_bar_icon.png",
-- new_label
--"Nivel "..my_lvl,
-- new_text_color
--"0xFFFFFF"
)
end
-- Inicializa HUD
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
local my_xp = xpro.get_player_xp(name)
local my_lvl = xpro.get_player_lvl(name)
hb.init_hudbar(
-- player
player,
-- identifier
"xpro:xp",
-- start_value
get_progress(my_xp, my_lvl),
-- start_max
nil,
-- start_hidden
false
)
end)
-- Registrar barra
hb.register_hudbar(
-- identifier
"xpro:xp",
-- text_color
"0xFFFFFF",
-- label
S("XP"),
-- textures
{
bar = "xpro_hudbars_bar_xp.png",
icon = "xpro_hudbars_icon_xp.png",
bgicon = "xpro_hudbars_bgicon_xp.png",
},
-- default_start_value
0,
-- default_start_max
100,
-- default_start_hidden
false,
-- format_string
"%s: %d%%"
)
-- Alterar barra ao adicionar XP
xpro.register_on_add_xp(function(name)
update_hb(name)
end)
-- Alterar barra ao remover XP
xpro.register_on_rem_xp(function(name)
update_hb(name)
end)
end
-- Exibir pontos recebidos no hub
-- Remover elemento do hud
local remover_hud = function(player, id)
if player == nil then return end
player:hud_remove(id)
end
-- Adicionar elemento no hud
local adicionar_hud = function(player, def, time)
if player == nil then return end
local id = player:hud_add(def)
-- Remover apos `time` segundos
minetest.after(time, remover_hud, player, id)
end
-- Alterar barra ao adicionar XP
xpro.register_on_add_xp(function(name, xp_added, lvl_changed)
-- Elemento
local def = {
hud_elem_type = "text",
position = {x=(math.random(1, 100)/100)*0.5+0.23,y=(math.random(1, 100)/100)*0.15+0.58},
scale = {x=500,y=500},
text = S("+@1XP", xp_added),
number = 0x00FF00,
alignment = {x=1,y=1},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def, 3)
-- Ao evoluir de nivel e liga
if lvl_changed == true then
local new_lvl = xpro.get_player_lvl(name)
local liga = xpro.ligas[new_lvl]
local def_bg_liga = {
hud_elem_type = "image",
position = {x=0.5,y=0.15},
scale = {x=0.3,y=0.3},
text = "(xpro_bg_alfa.png^[resize:500x500)^xpro_liga_bg.png",
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_bg_liga, 8)
local def_liga = {
hud_elem_type = "image",
position = {x=0.5,y=0.15},
scale = {x=0.27,y=0.27},
text = "("..liga.img..")^xpro_bg_alfa.png^[resize:500x500",
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_liga, 8)
local def_text_liga = {
hud_elem_type = "text",
position = {x=0.5,y=0.265},
scale = {x=500,y=500},
text = S("Liga @1", liga.name),
number = 0x00FF00,
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_text_liga, 8)
local def_text_lvl = {
hud_elem_type = "text",
position = {x=0.5,y=0.29},
scale = {x=500,y=500},
text = S("Nivel @1", new_lvl),
number = 0x00FF00,
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_text_lvl, 8)
minetest.sound_play("xpro_upgrade_lvl", {
to_player = name,
gain = 0.5,
})
end
end)
-- Alterar barra ao remover XP
xpro.register_on_rem_xp(function(name, xp_removed, lvl_changed)
-- Elemento
local def = {
hud_elem_type = "text",
position = {x=(math.random(1, 100)/100)*0.5+0.23,y=(math.random(1, 100)/100)*0.15+0.58},
scale = {x=500,y=500},
text = S("-@1XP", xp_removed),
number = 0xFF0000,
alignment = {x=1,y=1},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def, 5)
-- Ao evoluir de nivel e liga
if lvl_changed == true then
local new_lvl = xpro.get_player_lvl(name)
local liga = xpro.ligas[new_lvl]
local def_bg_liga = {
hud_elem_type = "image",
position = {x=0.5,y=0.15},
scale = {x=0.3,y=0.3},
text = "(xpro_bg_alfa.png^[resize:500x500)^xpro_liga_bg.png",
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_bg_liga, 8)
local def_liga = {
hud_elem_type = "image",
position = {x=0.5,y=0.15},
scale = {x=0.27,y=0.27},
text = "("..liga.img..")^xpro_bg_alfa.png^[resize:500x500",
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_liga, 8)
local def_text_liga = {
hud_elem_type = "text",
position = {x=0.5,y=0.265},
scale = {x=500,y=500},
text = S("Liga @1", liga.name),
number = 0xFF0000,
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_text_liga, 8)
local def_text_lvl = {
hud_elem_type = "text",
position = {x=0.5,y=0.29},
scale = {x=500,y=500},
text = S("Nivel @1", new_lvl),
number = 0xFF0000,
alignment = {x=0,y=0},
offset = {x=0, y=0},
}
adicionar_hud(minetest.get_player_by_name(name), def_text_lvl, 8)
minetest.sound_play("xpro_downgrade_lvl", {
to_player = name,
gain = 0.5,
})
end
end)

62
mods/xpro/init.lua Normal file
View File

@ -0,0 +1,62 @@
--[[
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 <http://www.gnu.org/licenses/>.
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")
-- Lib tror
xpro.tror = dofile(modpath.."/lib/tror.lua")
-- Variaveis personalizaveis
xpro.var = {}
-- API
dofile(modpath.."/tradutor.lua")
dofile(modpath.."/api.lua")
dofile(modpath.."/ligas.lua")
dofile(modpath.."/shop.lua")
dofile(modpath.."/sfinv.lua")
dofile(modpath.."/progresso.lua")
dofile(modpath.."/ranking.lua")
dofile(modpath.."/hud.lua")
-- Metodos para evoluir
dofile(modpath.."/metodos/die.lua")
dofile(modpath.."/metodos/craft.lua")
dofile(modpath.."/metodos/dig_node.lua")
dofile(modpath.."/metodos/place_node.lua")
-- Suporte para mods
dofile(modpath.."/mods_suportados/minetest_game.lua")
dofile(modpath.."/mods_suportados/farming_redo.lua")
dofile(modpath.."/mods_suportados/moreores.lua")
dofile(modpath.."/mods_suportados/3d_armor.lua")
dofile(modpath.."/mods_suportados/3d_armor_stand.lua")
dofile(modpath.."/mods_suportados/shields.lua")
dofile(modpath.."/mods_suportados/xdecor.lua")
notificar("OK")

45
mods/xpro/lib/intllib.lua Normal file
View File

@ -0,0 +1,45 @@
-- Fallback functions for when `intllib` is not installed.
-- Code released under Unlicense <http://unlicense.org>.
-- 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

302
mods/xpro/lib/memor.lua Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
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

152
mods/xpro/lib/tror.lua Normal file
View File

@ -0,0 +1,152 @@
--[[
Lib Tror 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/>.
Operações de troca de itens
]]
local tror = {}
-- Verificar viabilidade de uma troca
tror.verificar = function(player, item_rem, item_add)
if not player or not item_add or not item_rem then
minetest.log("error", "[Tror] Faltou dados em (em tror.verificar)")
return false
end
local inv = player:get_inventory()
-- Verificar jogador
if not inv:contains_item("main", item_rem) then
return 1 -- Jogador nao pode pagar
elseif not inv:room_for_item("main", item_add) then
return 2 -- Jogador com inventario lotado
end
return true
end
-- Realizar uma troca entre com um jogador
tror.trocar = function(player, item_rem, item_add, msg)
if not player or not item_add or not item_rem then
minetest.log("error", "[Tror] Faltou dados em (em tror.trocar)")
return false
end
local v = tror.verificar(player, item_rem, item_add)
if v ~= true then
if v == 1 then
if msg and msg.ins then
minetest.chat_send_player(player:get_player_name(), msg.ins)
end
return 1
elseif v == 2 then
if msg and msg.lot then
minetest.chat_send_player(player:get_player_name(), msg.lot)
end
return 2
else
minetest.log("error", "[Tror] Resultado inesperado em tror.trocar (v = "..dump(v)..")")
return false
end
end
local inv = player:get_inventory()
-- Retirar itens do inventario
local i = string.split(item_rem, " ")
local n = i[2] or 1
i = i[1]
for r=1, tonumber(n) do -- 1 eh o tanto que quero tirar
inv:remove_item("main", i) -- tira 1 por vez
end
inv:add_item("main", item_add)
if msg and msg.ok then
minetest.chat_send_player(player:get_player_name(), msg.ok)
end
return true
end
-- Realizar uma troca com um jogador
--[[
Retorna false caso o jogador nao tenha os itens requisitados
e dropa no local todos os itens que não couberem no inventario
]]
tror.trocar_plus = function(player, item_rem, item_add)
if not player then
minetest.log("error", "[Tror] Faltou player (em tror.trocar_plus)")
return false
end
if item_rem and not item_rem[1] then
minetest.log("error", "[Tror] argumento item_rem invalido (em tror.trocar_plus)")
return false
end
if item_add and not item_add[1] then
minetest.log("error", "[Tror] argumento item_add invalido (em tror.trocar_plus)")
return false
end
local pos = player:getpos()
local inv = player:get_inventory()
-- Verificar se o jogador possui os itens requisitados
local possui = true
if item_rem ~= nil then
for _,item in ipairs(item_rem) do
if not inv:contains_item("main", item) then
possui = false
break
end
end
end
-- Retorna false por jogador não ter os itens requisitados
if possui == false then
return false
end
-- Retira itens do jogador
if item_rem ~= nil then
for _,item in ipairs(item_rem) do
local i = string.split(item, " ")
local n = i[2] or 1
i = i[1]
for r=1, tonumber(n) do -- 1 eh o tanto que quero tirar
inv:remove_item("main", i) -- tira 1 por vez
end
end
end
-- Transfere todos os itens ao jogador (e dropa os que nao couberem no inventario)
local dropou = false
if item_add ~= nil then
for _,item in ipairs(item_add) do
if inv:room_for_item("main", item) then
inv:add_item("main", item)
else
dropou = true
minetest.env:add_item({x = pos.x + math.random() * 2 - 1, y = pos.y+1, z = pos.z + math.random() * 2 - 1}, item)
end
end
end
return true
end
return tror

63
mods/xpro/ligas.lua Normal file
View File

@ -0,0 +1,63 @@
--[[
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 <http://www.gnu.org/licenses/>.
Ligas dos Niveis
]]
local S = xpro.S
-- Tabela de Ligas
xpro.ligas = {
-- Liga Novato
{img="[inventorycube{default_dirt.png{default_dirt.png{default_dirt.png", name=S("Novato I")}, -- Nivel 1
{img="[inventorycube{default_grass.png{default_dirt.png&default_grass_side.png{default_dirt.png&default_grass_side.png", name=S("Novato II")}, -- Nivel 2
{img="default_apple.png", name=S("Novato III")}, -- Nivel 3
-- Liga Madeira
{img="default_stick.png", name=S("Madeira I")}, -- Nivel 4
{img="[inventorycube{default_wood.png{default_wood.png{default_wood.png", name=S("Madeira II")}, -- Nivel 5
{img="[inventorycube{default_tree_top.png{default_tree.png{default_tree.png", name=S("Madeira III")}, -- Nivel 6
{img="default_tool_woodshovel.png", name=S("Madeira IV")}, -- Nivel 7
{img="default_tool_woodaxe.png", name=S("Madeira V")}, -- Nivel 8
{img="default_tool_woodpick.png", name=S("Madeira VI")}, -- Nivel 9
{img="default_tool_woodsword.png", name=S("Madeira VII")}, -- Nivel 10
-- Liga Pedra
{img="[inventorycube{default_cobble.png{default_cobble.png{default_cobble.png", name=S("Pedra I")}, -- Nivel 11
{img="[inventorycube{default_stone.png{default_stone.png{default_stone.png", name=S("Pedra II")}, -- Nivel 12
{img="default_tool_stoneshovel.png", name=S("Pedra III")}, -- Nivel 13
{img="default_tool_stoneaxe.png", name=S("Pedra IV")}, -- Nivel 14
{img="default_tool_stonepick.png", name=S("Pedra V")}, -- Nivel 15
{img="default_tool_stonesword.png", name=S("Pedra VI")}, -- Nivel 16
-- Liga Ferro
{img="default_iron_lump.png", name=S("Ferro I")}, -- Nivel 17
{img="default_steel_ingot.png", name=S("Ferro II")}, -- Nivel 18
{img="default_tool_steelshovel.png", name=S("Ferro III")}, -- Nivel 19
{img="default_tool_steelaxe.png", name=S("Ferro IV")}, -- Nivel 20
{img="default_tool_steelpick.png", name=S("Ferro V")}, -- Nivel 21
{img="default_tool_steelsword.png", name=S("Ferro VI")}, -- Nivel 22
-- Liga Bronze
{img="default_bronze_ingot.png", name=S("Bronze II")}, -- Nivel 23
{img="default_tool_bronzeshovel.png", name=S("Bronze III")}, -- Nivel 24
{img="default_tool_bronzeaxe.png", name=S("Bronze IV")}, -- Nivel 25
{img="default_tool_bronzepick.png", name=S("Bronze V")}, -- Nivel 26
{img="default_tool_bronzesword.png", name=S("Bronze VI")}, -- Nivel 27
-- Liga Mese
{img="default_mese_crystal_fragment.png", name=S("Mese I")}, -- Nivel 28
{img="default_mese_crystal.png", name=S("Mese II")}, -- Nivel 29
{img="default_tool_meseshovel.png", name=S("Mese III")}, -- Nivel 30
{img="default_tool_meseaxe.png", name=S("Mese IV")}, -- Nivel 31
{img="default_tool_mesepick.png", name=S("Mese V")}, -- Nivel 32
{img="default_tool_mesesword.png", name=S("Mese VI")}, -- Nivel 33
-- Liga Diamante
{img="[inventorycube{default_stone.png&default_mineral_diamond.png{default_stone.png&default_mineral_diamond.png{default_stone.png&default_mineral_diamond.png", name=S("Diamante I")}, -- Nivel 34
{img="default_diamond.png", name=S("Diamante II")}, -- Nivel 35
{img="default_tool_diamondshovel.png", name=S("Diamante III")}, -- Nivel 36
{img="default_tool_diamondaxe.png", name=S("Diamante IV")}, -- Nivel 37
{img="default_tool_diamondpick.png", name=S("Diamante V")}, -- Nivel 38
{img="default_tool_diamondsword.png", name=S("Diamante VI")}, -- Nivel 39
}

View File

@ -0,0 +1 @@
api.lua hud.lua ligas.lua progresso.lua ranking.lua sfinv.lua shop.lua

BIN
mods/xpro/locale/en.mo Normal file

Binary file not shown.

267
mods/xpro/locale/en.po Normal file
View File

@ -0,0 +1,267 @@
# 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 <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-17 10:28-0300\n"
"PO-Revision-Date: 2018-07-17 10:28-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"
#: hud.lua
msgid "XP"
msgstr "XP"
#: hud.lua
msgid "+@1XP"
msgstr "+@1XP"
#: hud.lua sfinv.lua
msgid "Liga @1"
msgstr "League @1"
#: hud.lua sfinv.lua
msgid "Nivel @1"
msgstr "Level @1"
#: hud.lua
msgid "-@1XP"
msgstr "-@1XP"
#: ligas.lua
msgid "Novato I"
msgstr "Novice I"
#: ligas.lua
msgid "Novato II"
msgstr "Novice II"
#: ligas.lua
msgid "Novato III"
msgstr "Novice III"
#: ligas.lua
msgid "Madeira I"
msgstr "Wood I"
#: ligas.lua
msgid "Madeira II"
msgstr "Wood II"
#: ligas.lua
msgid "Madeira III"
msgstr "Wood III"
#: ligas.lua
msgid "Madeira IV"
msgstr "Wood IV"
#: ligas.lua
msgid "Madeira V"
msgstr "Wood V"
#: ligas.lua
msgid "Madeira VI"
msgstr "Wood VI"
#: ligas.lua
msgid "Madeira VII"
msgstr "Wood VII"
#: ligas.lua
msgid "Pedra I"
msgstr "Stone I"
#: ligas.lua
msgid "Pedra II"
msgstr "Stone II"
#: ligas.lua
msgid "Pedra III"
msgstr "Stone III"
#: ligas.lua
msgid "Pedra IV"
msgstr "Stone IV"
#: ligas.lua
msgid "Pedra V"
msgstr "Stone V"
#: ligas.lua
msgid "Pedra VI"
msgstr "Stone VI"
#: ligas.lua
msgid "Ferro I"
msgstr "Steel I"
#: ligas.lua
msgid "Ferro II"
msgstr "Steel II"
#: ligas.lua
msgid "Ferro III"
msgstr "Steel III"
#: ligas.lua
msgid "Ferro IV"
msgstr "Steel IV"
#: ligas.lua
msgid "Ferro V"
msgstr "Steel V"
#: ligas.lua
msgid "Ferro VI"
msgstr "Steel VI"
#: ligas.lua
msgid "Bronze II"
msgstr "Bronze II"
#: ligas.lua
msgid "Bronze III"
msgstr "Bronze III"
#: ligas.lua
msgid "Bronze IV"
msgstr "Bronze IV"
#: ligas.lua
msgid "Bronze V"
msgstr "Bronze V"
#: ligas.lua
msgid "Bronze VI"
msgstr "Bronze VI"
#: ligas.lua
msgid "Mese I"
msgstr "Mese I"
#: ligas.lua
msgid "Mese II"
msgstr "Mese II"
#: ligas.lua
msgid "Mese III"
msgstr "Mese III"
#: ligas.lua
msgid "Mese IV"
msgstr "Mese IV"
#: ligas.lua
msgid "Mese V"
msgstr "Mese V"
#: ligas.lua
msgid "Mese VI"
msgstr "Mese VI"
#: ligas.lua
msgid "Diamante I"
msgstr "Diamond I"
#: ligas.lua
msgid "Diamante II"
msgstr "Diamond II"
#: ligas.lua
msgid "Diamante III"
msgstr "Diamond III"
#: ligas.lua
msgid "Diamante IV"
msgstr "Diamond IV"
#: ligas.lua
msgid "Diamante V"
msgstr "Diamond V"
#: ligas.lua
msgid "Diamante VI"
msgstr "Diamond VI"
#: ranking.lua
msgid "Pontos"
msgstr "Score"
#: ranking.lua
msgid "Jogador"
msgstr "Player"
#: sfinv.lua
msgid "Nivel"
msgstr "Level"
#: sfinv.lua
msgid "Pontos: @1"
msgstr "Score: @1"
#: sfinv.lua shop.lua
msgid "Cash XP: @1"
msgstr "XP Cash: @1"
#: sfinv.lua
msgid "Loja de Premios"
msgstr "Awards Store"
#: sfinv.lua
msgid "Ranking Global"
msgstr "Global Ranking"
#: sfinv.lua
msgid "Progresso"
msgstr "Progress"
#: shop.lua
msgid "Loja de Itens por XP"
msgstr "Awards Store"
#: shop.lua
msgid "Escolha um Item"
msgstr "Choose an item"
#: shop.lua
msgid "Custo: @1 CashXP"
msgstr "Cost: @1 XPCash"
#: shop.lua
msgid "Unidades: @1"
msgstr "Units: @1"
#: shop.lua
msgid "Comprar"
msgstr "Buy"
#: shop.lua
msgid "Cash XP insuficiente"
msgstr "Insufficient XPCash"
#: shop.lua
msgid "Inventario lotado"
msgstr "Full inventory"
#: shop.lua
msgid "Adiquirido"
msgstr "Acquired"
#: shop.lua
msgid "Pedras"
msgstr "Stones"
#: shop.lua
msgid "Pedregulho"
msgstr "Cobble"

BIN
mods/xpro/locale/pt.mo Normal file

Binary file not shown.

267
mods/xpro/locale/pt.po Normal file
View File

@ -0,0 +1,267 @@
# 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 <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-17 10:28-0300\n"
"PO-Revision-Date: 2018-07-17 10:28-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"
#: hud.lua
msgid "XP"
msgstr "XP"
#: hud.lua
msgid "+@1XP"
msgstr "+@1XP"
#: hud.lua sfinv.lua
msgid "Liga @1"
msgstr "Liga @1"
#: hud.lua sfinv.lua
msgid "Nivel @1"
msgstr "Nivel @1"
#: hud.lua
msgid "-@1XP"
msgstr "-@1XP"
#: ligas.lua
msgid "Novato I"
msgstr "Novato I"
#: ligas.lua
msgid "Novato II"
msgstr "Novato II"
#: ligas.lua
msgid "Novato III"
msgstr "Novato III"
#: ligas.lua
msgid "Madeira I"
msgstr "Madeira I"
#: ligas.lua
msgid "Madeira II"
msgstr "Madeira II"
#: ligas.lua
msgid "Madeira III"
msgstr "Madeira III"
#: ligas.lua
msgid "Madeira IV"
msgstr "Madeira IV"
#: ligas.lua
msgid "Madeira V"
msgstr "Madeira V"
#: ligas.lua
msgid "Madeira VI"
msgstr "Madeira VI"
#: ligas.lua
msgid "Madeira VII"
msgstr "Madeira VII"
#: ligas.lua
msgid "Pedra I"
msgstr "Pedra I"
#: ligas.lua
msgid "Pedra II"
msgstr "Pedra II"
#: ligas.lua
msgid "Pedra III"
msgstr "Pedra III"
#: ligas.lua
msgid "Pedra IV"
msgstr "Pedra IV"
#: ligas.lua
msgid "Pedra V"
msgstr "Pedra V"
#: ligas.lua
msgid "Pedra VI"
msgstr "Pedra VI"
#: ligas.lua
msgid "Ferro I"
msgstr "Ferro I"
#: ligas.lua
msgid "Ferro II"
msgstr "Ferro II"
#: ligas.lua
msgid "Ferro III"
msgstr "Ferro III"
#: ligas.lua
msgid "Ferro IV"
msgstr "Ferro IV"
#: ligas.lua
msgid "Ferro V"
msgstr "Ferro V"
#: ligas.lua
msgid "Ferro VI"
msgstr "Ferro VI"
#: ligas.lua
msgid "Bronze II"
msgstr "Bronze II"
#: ligas.lua
msgid "Bronze III"
msgstr "Bronze III"
#: ligas.lua
msgid "Bronze IV"
msgstr "Bronze IV"
#: ligas.lua
msgid "Bronze V"
msgstr "Bronze V"
#: ligas.lua
msgid "Bronze VI"
msgstr "Bronze VI"
#: ligas.lua
msgid "Mese I"
msgstr "Mese I"
#: ligas.lua
msgid "Mese II"
msgstr "Mese II"
#: ligas.lua
msgid "Mese III"
msgstr "Mese III"
#: ligas.lua
msgid "Mese IV"
msgstr "Mese IV"
#: ligas.lua
msgid "Mese V"
msgstr "Mese V"
#: ligas.lua
msgid "Mese VI"
msgstr "Mese VI"
#: ligas.lua
msgid "Diamante I"
msgstr "Diamante I"
#: ligas.lua
msgid "Diamante II"
msgstr "Diamante II"
#: ligas.lua
msgid "Diamante III"
msgstr "Diamante III"
#: ligas.lua
msgid "Diamante IV"
msgstr "Diamante IV"
#: ligas.lua
msgid "Diamante V"
msgstr "Diamante V"
#: ligas.lua
msgid "Diamante VI"
msgstr "Diamante VI"
#: ranking.lua
msgid "Pontos"
msgstr "Pontos"
#: ranking.lua
msgid "Jogador"
msgstr "Jogador"
#: sfinv.lua
msgid "Nivel"
msgstr "Nivel"
#: sfinv.lua
msgid "Pontos: @1"
msgstr "Pontos: @1"
#: sfinv.lua shop.lua
msgid "Cash XP: @1"
msgstr "Cash XP: @1"
#: sfinv.lua
msgid "Loja de Premios"
msgstr "Loja de Premios"
#: sfinv.lua
msgid "Ranking Global"
msgstr "Ranking Global"
#: sfinv.lua
msgid "Progresso"
msgstr "Progresso"
#: shop.lua
msgid "Loja de Itens por XP"
msgstr "Loja de Itens por XP"
#: shop.lua
msgid "Escolha um Item"
msgstr "Escolha um Item"
#: shop.lua
msgid "Custo: @1 CashXP"
msgstr "Custo: @1 CashXP"
#: shop.lua
msgid "Unidades: @1"
msgstr "Unidades: @1"
#: shop.lua
msgid "Comprar"
msgstr "Comprar"
#: shop.lua
msgid "Cash XP insuficiente"
msgstr "Cash XP insuficiente"
#: shop.lua
msgid "Inventario lotado"
msgstr "Inventario lotado"
#: shop.lua
msgid "Adiquirido"
msgstr "Adiquirido"
#: shop.lua
msgid "Pedras"
msgstr "Pedras"
#: shop.lua
msgid "Pedregulho"
msgstr "Pedregulho"

View File

@ -0,0 +1,266 @@
# 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 <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-17 10:28-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: hud.lua
msgid "XP"
msgstr ""
#: hud.lua
msgid "+@1XP"
msgstr ""
#: hud.lua sfinv.lua
msgid "Liga @1"
msgstr ""
#: hud.lua sfinv.lua
msgid "Nivel @1"
msgstr ""
#: hud.lua
msgid "-@1XP"
msgstr ""
#: ligas.lua
msgid "Novato I"
msgstr ""
#: ligas.lua
msgid "Novato II"
msgstr ""
#: ligas.lua
msgid "Novato III"
msgstr ""
#: ligas.lua
msgid "Madeira I"
msgstr ""
#: ligas.lua
msgid "Madeira II"
msgstr ""
#: ligas.lua
msgid "Madeira III"
msgstr ""
#: ligas.lua
msgid "Madeira IV"
msgstr ""
#: ligas.lua
msgid "Madeira V"
msgstr ""
#: ligas.lua
msgid "Madeira VI"
msgstr ""
#: ligas.lua
msgid "Madeira VII"
msgstr ""
#: ligas.lua
msgid "Pedra I"
msgstr ""
#: ligas.lua
msgid "Pedra II"
msgstr ""
#: ligas.lua
msgid "Pedra III"
msgstr ""
#: ligas.lua
msgid "Pedra IV"
msgstr ""
#: ligas.lua
msgid "Pedra V"
msgstr ""
#: ligas.lua
msgid "Pedra VI"
msgstr ""
#: ligas.lua
msgid "Ferro I"
msgstr ""
#: ligas.lua
msgid "Ferro II"
msgstr ""
#: ligas.lua
msgid "Ferro III"
msgstr ""
#: ligas.lua
msgid "Ferro IV"
msgstr ""
#: ligas.lua
msgid "Ferro V"
msgstr ""
#: ligas.lua
msgid "Ferro VI"
msgstr ""
#: ligas.lua
msgid "Bronze II"
msgstr ""
#: ligas.lua
msgid "Bronze III"
msgstr ""
#: ligas.lua
msgid "Bronze IV"
msgstr ""
#: ligas.lua
msgid "Bronze V"
msgstr ""
#: ligas.lua
msgid "Bronze VI"
msgstr ""
#: ligas.lua
msgid "Mese I"
msgstr ""
#: ligas.lua
msgid "Mese II"
msgstr ""
#: ligas.lua
msgid "Mese III"
msgstr ""
#: ligas.lua
msgid "Mese IV"
msgstr ""
#: ligas.lua
msgid "Mese V"
msgstr ""
#: ligas.lua
msgid "Mese VI"
msgstr ""
#: ligas.lua
msgid "Diamante I"
msgstr ""
#: ligas.lua
msgid "Diamante II"
msgstr ""
#: ligas.lua
msgid "Diamante III"
msgstr ""
#: ligas.lua
msgid "Diamante IV"
msgstr ""
#: ligas.lua
msgid "Diamante V"
msgstr ""
#: ligas.lua
msgid "Diamante VI"
msgstr ""
#: ranking.lua
msgid "Pontos"
msgstr ""
#: ranking.lua
msgid "Jogador"
msgstr ""
#: sfinv.lua
msgid "Nivel"
msgstr ""
#: sfinv.lua
msgid "Pontos: @1"
msgstr ""
#: sfinv.lua shop.lua
msgid "Cash XP: @1"
msgstr ""
#: sfinv.lua
msgid "Loja de Premios"
msgstr ""
#: sfinv.lua
msgid "Ranking Global"
msgstr ""
#: sfinv.lua
msgid "Progresso"
msgstr ""
#: shop.lua
msgid "Loja de Itens por XP"
msgstr ""
#: shop.lua
msgid "Escolha um Item"
msgstr ""
#: shop.lua
msgid "Custo: @1 CashXP"
msgstr ""
#: shop.lua
msgid "Unidades: @1"
msgstr ""
#: shop.lua
msgid "Comprar"
msgstr ""
#: shop.lua
msgid "Cash XP insuficiente"
msgstr ""
#: shop.lua
msgid "Inventario lotado"
msgstr ""
#: shop.lua
msgid "Adiquirido"
msgstr ""
#: shop.lua
msgid "Pedras"
msgstr ""
#: shop.lua
msgid "Pedregulho"
msgstr ""

63
mods/xpro/locale/xpro..tr Normal file
View File

@ -0,0 +1,63 @@
### Arquivo gerado por xpro apartir de en.po
# textdomain: xpro
Diamond VI=Diamond VI
Mese III=Mese III
Acquired=Acquired
Mese VI=Mese VI
Units: @1=Units: @1
Wood VI=Wood VI
Score=Score
XP Cash: @1=XP Cash: @1
Novice II=Novice II
Wood I=Wood I
XP=XP
Score: @1=Score: @1
Stone V=Stone V
Steel II=Steel II
Bronze V=Bronze V
Awards Store=Awards Store
Wood II=Wood II
Wood IV=Wood IV
Steel I=Steel I
Novice I=Novice I
Cost: @1 XPCash=Cost: @1 XPCash
Mese I=Mese I
+@1XP=+@1XP
Cobble=Cobble
Steel VI=Steel VI
Bronze II=Bronze II
Choose an item=Choose an item
Diamond I=Diamond I
Full inventory=Full inventory
Wood VII=Wood VII
Steel IV=Steel IV
Bronze III=Bronze III
Diamond V=Diamond V
Diamond II=Diamond II
Player=Player
Buy=Buy
Novice III=Novice III
Stone VI=Stone VI
Mese II=Mese II
Steel V=Steel V
Stone I=Stone I
Diamond IV=Diamond IV
Wood V=Wood V
Mese IV=Mese IV
Stone II=Stone II
Diamond III=Diamond III
Bronze VI=Bronze VI
Stone III=Stone III
Level=Level
Wood III=Wood III
League @1=League @1
Bronze IV=Bronze IV
Insufficient XPCash=Insufficient XPCash
Global Ranking=Global Ranking
Progress=Progress
Mese V=Mese V
Stones=Stones
Stone IV=Stone IV
Level @1=Level @1
Steel III=Steel III
-@1XP=-@1XP

View File

@ -0,0 +1,63 @@
### Arquivo gerado por xpro apartir de en.po
# textdomain: xpro
Diamond VI=Diamond VI
Mese III=Mese III
Acquired=Acquired
Mese VI=Mese VI
Units: @1=Units: @1
Wood VI=Wood VI
Score=Score
XP Cash: @1=XP Cash: @1
Novice II=Novice II
Wood I=Wood I
XP=XP
Score: @1=Score: @1
Stone V=Stone V
Steel II=Steel II
Bronze V=Bronze V
Awards Store=Awards Store
Wood II=Wood II
Wood IV=Wood IV
Steel I=Steel I
Novice I=Novice I
Cost: @1 XPCash=Cost: @1 XPCash
Mese I=Mese I
+@1XP=+@1XP
Cobble=Cobble
Steel VI=Steel VI
Bronze II=Bronze II
Choose an item=Choose an item
Diamond I=Diamond I
Full inventory=Full inventory
Wood VII=Wood VII
Steel IV=Steel IV
Bronze III=Bronze III
Diamond V=Diamond V
Diamond II=Diamond II
Player=Player
Buy=Buy
Novice III=Novice III
Stone VI=Stone VI
Mese II=Mese II
Steel V=Steel V
Stone I=Stone I
Diamond IV=Diamond IV
Wood V=Wood V
Mese IV=Mese IV
Stone II=Stone II
Diamond III=Diamond III
Bronze VI=Bronze VI
Stone III=Stone III
Level=Level
Wood III=Wood III
League @1=League @1
Bronze IV=Bronze IV
Insufficient XPCash=Insufficient XPCash
Global Ranking=Global Ranking
Progress=Progress
Mese V=Mese V
Stones=Stones
Stone IV=Stone IV
Level @1=Level @1
Steel III=Steel III
-@1XP=-@1XP

View File

@ -0,0 +1,63 @@
### Arquivo gerado por xpro apartir de pt.po
# textdomain: xpro
Diamond VI=Diamante VI
Mese III=Mese III
Acquired=Adiquirido
Mese VI=Mese VI
Units: @1=Unidades: @1
Wood VI=Madeira VI
Score=Pontos
XP Cash: @1=Cash XP: @1
Novice II=Novato II
Wood I=Madeira I
XP=XP
Score: @1=Pontos: @1
Stone V=Pedra V
Steel II=Ferro II
Bronze V=Bronze V
Awards Store=Loja de Premios
Wood II=Madeira II
Wood IV=Madeira IV
Steel I=Ferro I
Novice I=Novato I
Cost: @1 XPCash=Custo: @1 CashXP
Mese I=Mese I
+@1XP=+@1XP
Cobble=Pedregulho
Steel VI=Ferro VI
Bronze II=Bronze II
Choose an item=Escolha um Item
Diamond I=Diamante I
Full inventory=Inventario lotado
Wood VII=Madeira VII
Steel IV=Ferro IV
Bronze III=Bronze III
Diamond V=Diamante V
Diamond II=Diamante II
Player=Jogador
Buy=Comprar
Novice III=Novato III
Stone VI=Pedra VI
Mese II=Mese II
Steel V=Ferro V
Stone I=Pedra I
Diamond IV=Diamante IV
Wood V=Madeira V
Mese IV=Mese IV
Stone II=Pedra II
Diamond III=Diamante III
Bronze VI=Bronze VI
Stone III=Pedra III
Level=Nivel
Wood III=Madeira III
League @1=Liga @1
Bronze IV=Bronze IV
Insufficient XPCash=Cash XP insuficiente
Global Ranking=Ranking Global
Progress=Progresso
Mese V=Mese V
Stones=Pedras
Stone IV=Pedra IV
Level @1=Nivel @1
Steel III=Ferro III
-@1XP=-@1XP

View File

@ -0,0 +1,33 @@
--[[
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 <http://www.gnu.org/licenses/>.
Eventos de ganho ou perca de XP ao craftar um node
]]
-- Lista de itens que geram recompensa
xpro.craft_xp_list = {}
-- Chamada global
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
-- Verifica se node gera XP
local name = itemstack:get_name()
if xpro.craft_xp_list[name] then
if xpro.craft_xp_list[name] > 0 then
xpro.add_xp(player:get_player_name(), xpro.craft_xp_list[name])
else
xpro.rem_xp(player:get_player_name(), math.abs(xpro.craft_xp_list[name]))
end
end
end)
-- Registrar item para o evento
xpro.register_on_craft = function(name, xp)
if tonumber(xp) == 0 then return end
xpro.craft_xp_list[name] = tonumber(xp)
end

29
mods/xpro/metodos/die.lua Normal file
View File

@ -0,0 +1,29 @@
--[[
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 <http://www.gnu.org/licenses/>.
Regredir pontos de XP ao morrer
]]
-- Chamada Global
minetest.register_on_dieplayer(function(player)
local name = player:get_player_name()
local lvl = xpro.get_player_lvl(name)
local xp_rem = 25*lvl
xpro.rem_xp(name, xp_rem)
end)

View File

@ -0,0 +1,40 @@
--[[
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 <http://www.gnu.org/licenses/>.
Eventos de ganho ou perca de XP ao cavar um node
]]
-- Lista de itens que geram recompensa
xpro.dig_node_xp_list = {}
-- Chamada global
minetest.register_on_dignode(function(pos, oldnode, digger)
-- Verifica se node gera XP
if xpro.dig_node_xp_list[oldnode.name] then
if xpro.dig_node_xp_list[oldnode.name] > 0 then
xpro.add_xp(digger:get_player_name(), xpro.dig_node_xp_list[oldnode.name])
else
xpro.rem_xp(digger:get_player_name(), math.abs(xpro.dig_node_xp_list[oldnode.name]))
end
end
end)
-- Registrar item para o evento
xpro.register_on_dignode = function(name, xp)
if tonumber(xp) == 0 then return end
xpro.dig_node_xp_list[name] = xp
end

View File

@ -0,0 +1,42 @@
--[[
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 <http://www.gnu.org/licenses/>.
Eventos de ganho ou perca de XP ao colocar um node
]]
-- Lista de itens que geram recompensa
xpro.place_node_xp_list = {}
-- Chamada global
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
-- Verifica se node gera XP
if xpro.place_node_xp_list[newnode.name] then
if xpro.place_node_xp_list[newnode.name] > 0 then
xpro.add_xp(placer:get_player_name(), xpro.place_node_xp_list[newnode.name])
else
xpro.rem_xp(placer:get_player_name(), math.abs(xpro.place_node_xp_list[newnode.name]))
end
end
end)
-- Registrar item para o evento
xpro.register_on_placenode = function(name, xp)
if tonumber(xp) == 0 then return end
xpro.place_node_xp_list[name] = xp
end

1
mods/xpro/mod.conf Normal file
View File

@ -0,0 +1 @@
name = xpro

View File

@ -0,0 +1,59 @@
--[[
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 <http://www.gnu.org/licenses/>.
Mod 3D_Armor
]]
if not minetest.get_modpath("3d_armor") then return end
-- Traduções
local S = xpro.S
-- Crafts
for name,xp in pairs({
-- Capacete
["3d_armor:helmet_wood"] = 1,
["3d_armor:helmet_cactus"] = 1,
["3d_armor:helmet_steel"] = 3,
["3d_armor:helmet_bronze"] = 6,
["3d_armor:helmet_diamond"] = 9,
["3d_armor:helmet_gold"] = 5,
["3d_armor:helmet_mithril"] = 8,
-- Peitoral
["3d_armor:chestplate_wood"] = 1,
["3d_armor:chestplate_cactus"] = 1,
["3d_armor:chestplate_steel"] = 7,
["3d_armor:chestplate_bronze"] = 12,
["3d_armor:chestplate_diamond"] = 16,
["3d_armor:chestplate_gold"] = 14,
["3d_armor:chestplate_mithril"] = 15,
-- Calças
["3d_armor:leggings_wood"] = 1,
["3d_armor:leggings_cactus"] = 1,
["3d_armor:leggings_steel"] = 4,
["3d_armor:leggings_bronze"] = 7,
["3d_armor:leggings_diamond"] = 14,
["3d_armor:leggings_gold"] = 11,
["3d_armor:leggings_mithril"] = 13,
-- Botas
["3d_armor:boots_wood"] = 1,
["3d_armor:boots_wood"] = 1,
["3d_armor:boots_cactus"] = 1,
["3d_armor:boots_steel"] = 3,
["3d_armor:boots_bronze"] = 5,
["3d_armor:boots_diamond"] = 7,
["3d_armor:boots_gold"] = 5,
["3d_armor:boots_mithril"] = 6,
}) do
xpro.register_on_craft(name, xp)
end

View File

@ -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 <http://www.gnu.org/licenses/>.
Mod 3D_Armor_Stand
]]
if not minetest.get_modpath("3d_armor_stand") then return end
-- Traduções
local S = xpro.S
-- Crafts
for name,xp in pairs({
["3d_armor_stand:armor_stand"] = 1,
["3d_armor_stand:locked_armor_stand"] = 1,
}) do
xpro.register_on_craft(name, xp)
end

View File

@ -0,0 +1,76 @@
--[[
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 <http://www.gnu.org/licenses/>.
Mod farming do TenPlus
]]
if farming == nil or farming.mod ~= "redo" then return end
-- Traduções
local S = xpro.S
-- Crafts
for name,xp in pairs({
-- Utensilios
["farming:baking_tray"] = 1,
["farming:cutting_board"] = 1,
["farming:mixing_bowl"] = 1,
["farming:juicer"] = 1,
["farming:mortar_pestle"] = 1,
["farming:saucepan"] = 1,
-- Alimentos complexos
["farming:beetroot_soup"] = 1,
["farming:muffin_blueberry"] = 1,
["farming:blueberry_pie"] = 1,
["farming:chili_bowl"] = 1,
["farming:pot"] = 1,
["farming:potato_salad"] = 1,
["farming:garlic_bread"] = 1,
["farming:pineapple_juice"] = 1,
["farming:porridge"] = 1,
["farming:skillet"] = 1,
["farming:toast_sandwich"] = 1,
["farming:donut_chocolate"] = 1,
["farming:donut_apple"] = 1,
["farming:turkish_delight"] = 1,
}) do
xpro.register_on_craft(name, xp)
end
-- Ao cavar node
for name,xp in pairs({
-- Plantas
["farming:pineapple_8"] = 1,
["farming:chili_8"] = 1,
["farming:pepper_5"] = 1,
["farming:pea_5"] = 1,
["farming:beetroot_5"] = 1,
["farming:onion_5"] = 1,
["farming:garlic_5"] = 1,
["farming:barley_7"] = 1,
["farming:beanpole_5"] = 1,
["farming:blueberry_4"] = 1,
["farming:raspberry_4"] = 1,
["farming:carrot_8"] = 1,
["farming:cocoa_4"] = 1,
["farming:coffee_5"] = 1,
["farming:corn_8"] = 1,
["farming:cucumber_4"] = 1,
["farming:grapes_8"] = 1,
["farming:hemp_8"] = 1,
["farming:melon_8"] = 1,
["farming:potato_4"] = 1,
["farming:pumpkin_8"] = 1,
["farming:rhubarb_3"] = 1,
["farming:tomato_8"] = 1,
}) do
xpro.register_on_dignode(name, xp)
end

View File

@ -0,0 +1,144 @@
--[[
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 <http://www.gnu.org/licenses/>.
Mods do Minetest Game
]]
-- Traduções
local S = xpro.S
-- Crafts
for name,xp in pairs({
-- Utensilios
["bucket:bucket_empty"] = 2,
["default:skeleton_key"] = 1,
-- Moveis
["default:furnace"] = 1,
["doors:door_steel"] = 3,
["doors:trapdoor_steel"] = 2,
["beds:bed"] = 1,
["beds:fancy_bed"] = 1,
["default:meselamp"] = 3,
["default:sign_wall_steel"] = 2,
["default:ladder_steel"] = 2,
["default:bookshelf"] = 1,
["default:shelf"] = 1,
["default:chest"] = 1,
["default:chest_locked"] = 2,
-- Tools
["default:pick_wood"] = 1,
["default:pick_stone"] = 1,
["default:pick_steel"] = 2,
["default:pick_bronze"] = 3,
["default:pick_mese"] = 4,
["default:pick_diamond"] = 5,
["default:shovel_wood"] = 1,
["default:shovel_stone"] = 1,
["default:shovel_steel"] = 1,
["default:shovel_bronze"] = 2,
["default:shovel_mese"] = 3,
["default:shovel_diamond"] = 4,
["default:axe_wood"] = 1,
["default:axe_stone"] = 1,
["default:axe_steel"] = 2,
["default:axe_bronze"] = 3,
["default:axe_mese"] = 4,
["default:axe_diamond"] = 5,
["default:sword_wood"] = 1,
["default:sword_stone"] = 1,
["default:sword_steel"] = 2,
["default:sword_bronze"] = 3,
["default:sword_mese"] = 4,
["default:sword_diamond"] = 5,
["farming:hoe_wood"] = 1,
["farming:hoe_stone"] = 1,
["farming:hoe_steel"] = 2,
["farming:hoe_bronze"] = 3,
["farming:hoe_mese"] = 4,
["farming:hoe_diamond"] = 5,
-- Carts
["carts:cart"] = 2,
["carts:rail"] = 1,
["carts:powerrail"] = 1,
["carts:brakerail"] = 1,
-- Farming
["farming:flour"] = 1,
}) do
xpro.register_on_craft(name, xp)
end
-- Ao cavar node
for name,xp in pairs({
["default:stone_with_coal"] = 1,
["default:stone_with_tin"] = 1,
["default:stone_with_copper"] = 2,
["default:stone_with_iron"] = 3,
["default:stone_with_gold"] = 5,
["default:stone_with_mese"] = 5,
["default:stone_with_diamond"] = 5,
-- Farming
["farming:wheat_8"] = 1,
["farming:cotton_8"] = 1,
}) do
xpro.register_on_dignode(name, xp)
end
-- Ao colocar node
for name,xp in pairs({
--["default:stone_with_coal"] = 1,
--["default:stone_with_tin"] = 1,
}) do
xpro.register_on_placenode(name, xp)
end
-- Premios basicos
for _,dados in ipairs({
{name=nil, item="default:mese_crystal", qtd=3, custo=180},
{name=nil, item="default:diamond", qtd=3, custo=250},
{name=nil, item="default:gold_ingot", qtd=5, custo=400},
{name=nil, item="default:steel_ingot", qtd=10, custo=250},
{name=nil, item="default:coal_lump", qtd=30, custo=100},
{name=nil, item="default:brick", qtd=30, custo=180},
{name=nil, item="default:clay", qtd=40, custo=180},
{name=nil, item="default:glass", qtd=50, custo=130},
{name=nil, item="default:stone", qtd=50, custo=150},
{name=nil, item="default:desert_stone", qtd=50, custo=150},
{name=nil, item="default:sand", qtd=50, custo=100},
{name=nil, item="default:desert_sand", qtd=50, custo=100},
{name=nil, item="default:silver_sand", qtd=50, custo=100},
{name=nil, item="default:sandstone", qtd=50, custo=150},
{name=nil, item="default:desert_sandstone", qtd=50, custo=150},
{name=nil, item="default:silver_sandstone", qtd=50, custo=150},
{name=nil, item="default:tree", qtd=50, custo=200},
{name=nil, item="default:jungletree", qtd=50, custo=200},
{name=nil, item="default:aspen_tree", qtd=50, custo=200},
{name=nil, item="default:acacia_tree", qtd=50, custo=200},
{name=nil, item="default:pine_tree", qtd=50, custo=200},
{name=nil, item="wool:white", qtd=35, custo=180},
{name=nil, item="default:obsidian", qtd=35, custo=180},
}) do
-- Registrar apenas premios existentes
if minetest.registered_items[dados.item]
--or minetest.registered_nodes[dados.item]
--or minetest.registered_craftitems[dados.item]
--or minetest.registered_tools[dados.item]
then
if dados.name == nil then
dados.name = minetest.registered_items[dados.item].description
end
xpro.registrar_premio(dados.name, {
item=dados.item,
qtd=dados.qtd,
custo=dados.custo,
})
end
end

View File

@ -0,0 +1,45 @@
--[[
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 <http://www.gnu.org/licenses/>.
Mod Moreores
]]
if not minetest.get_modpath("moreores") then return end
-- Traduções
local S = xpro.S
-- Crafts
for name,xp in pairs({
-- Ferramentas
["moreores:pick_mithril"] = 4,
["moreores:pick_silver"] = 1,
["moreores:shovel_mithril"] = 4,
["moreores:shovel_silver"] = 1,
["moreores:axe_mithril"] = 4,
["moreores:axe_silver"] = 1,
["moreores:sword_mithril"] = 4,
["moreores:sword_silver"] = 1,
["moreores:hoe_mithril"] = 4,
["moreores:hoe_silver"] = 1,
}) do
xpro.register_on_craft(name, xp)
end
-- Ao cavar node
for name,xp in pairs({
-- Minerios
["moreores:mineral_silver"] = 1,
["moreores:mineral_mithril"] = 4,
}) do
xpro.register_on_dignode(name, xp)
end

View File

@ -0,0 +1,35 @@
--[[
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 <http://www.gnu.org/licenses/>.
Mod Shields
]]
if not minetest.get_modpath("shields") then return end
-- Traduções
local S = xpro.S
-- Crafts
for name,xp in pairs({
["shields:shield_wood"] = 1,
["shields:shield_enhanced_wood"] = 1,
["shields:shield_cactus"] = 1,
["shields:shield_enhanced_cactus"] = 2,
["shields:shield_steel"] = 7,
["shields:shield_bronze"] = 12,
["shields:shield_diamond"] = 16,
["shields:shield_gold"] = 14,
["shields:shield_mithril"] = 15,
}) do
xpro.register_on_craft(name, xp)
end

View File

@ -0,0 +1,69 @@
--[[
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 <http://www.gnu.org/licenses/>.
Mod Xdecor
]]
if not minetest.get_modpath("xdecor") then return end
-- Traduções
local S = xpro.S
-- Crafts
for name,xp in pairs({
["xdecor:iron_lightbox"] = 2,
["xdecor:enchantment_table"] = 8,
["xdecor:cauldron_empty"] = 3,
["xdecor:enderchest"] = 1,
["xdecor:coalstone_tile"] = 3,
["xdecor:barrel"] = 1,
["xdecor:cabinet"] = 1,
["xdecor:cactusbrick"] = 1,
["xdecor:hive"] = 1,
["xdecor:barricade"] = 1,
["xdecor:lantern"] = 1,
["xdecor:itemframe"] = 1,
["xdecor:desertstone_tile"] = 1,
["xdecor:cushion"] = 1,
["xdecor:mailbox"] = 1,
["xdecor:moonbrick"] = 1,
["xdecor:empty_shelf"] = 1,
["xdecor:multishelf"] = 1,
["xdecor:packed_ice"] = 1,
["xdecor:stone_rune"] = 1,
["xdecor:stone_tile"] = 1,
["xdecor:wooden_lightbox"] = 1,
["xdecor:woodframed_glass"] = 1,
["xdecor:potted_geranium"] = 1,
["xdecor:potted_rose"] = 1,
["xdecor:potted_tulip"] = 1,
["xdecor:potted_viola"] = 1,
["xdecor:potted_dandelion_white"] = 1,
["xdecor:potted_dandelion_yellow"] = 1,
["xdecor:potted_geranium"] = 1,
["xdecor:tv"] = 1,
["xdecor:tatami"] = 1,
["xdecor:table"] = 1,
["xdecor:workbench"] = 1,
["xdecor:wood_tile"] = 1,
["doors:woodglass_door"] = 1,
["xdecor:slide_door"] = 1,
["xdecor:screen_door"] = 1,
["xdecor:prison_door"] = 2,
["xdecor:rusty_prison_door"] = 2,
["xdecor:japanese_door"] = 1,
["xdecor:rope"] = 1,
["xdecor:painting_1"] = 1,
}) do
xpro.register_on_craft(name, xp)
end

18
mods/xpro/progresso.lua Normal file
View File

@ -0,0 +1,18 @@
--[[
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 <http://www.gnu.org/licenses/>.
Ao evoluir ou regradir niveis
]]

156
mods/xpro/ranking.lua Normal file
View File

@ -0,0 +1,156 @@
--[[
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 <http://www.gnu.org/licenses/>.
Gerenciamento do Ranking
]]
-- Traduções
local S = xpro.S
-- 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 att_name = {}
local rank = xpro.get_rank()
local pontos = 0
if xpro.bd.verif("jogador_"..name, "xp") == true then pontos = xpro.bd.pegar("jogador_"..name, "xp") end
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
-- Marca para reclassificalos posteriormente
table.insert(att_name, tostring(m1.name))
-- 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))
-- Recoloca os necessarios
for _, n in ipairs(att_name) do
xpro.update_rank(n)
break
end
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,7]"
..default.gui_bg
..default.gui_bg_img
.."label[0.6,0.4;"..S("Pontos").."]"
.."label[2.4,0.4;"..S("Jogador").."]"
-- Monta Ranking
local rank = xpro.get_rank()
for x=1, 10 do
local w = (0.4+(0.5*x))+(0.1*x)
local liga = nil
if xpro.bd.verif("jogador_"..rank[tostring(x)].name, "lvl") == true then liga = xpro.ligas[xpro.bd.pegar("jogador_"..rank[tostring(x)].name, "lvl")] end
if liga ~= nil then
liga = "image[1.75,"..(w*0.995-0.05)..";0.66,0.66;"..liga.img.."]"
else
liga = ""
end
xpro.ranking_formspec = xpro.ranking_formspec .."label[0.6,"..w..";"..rank[tostring(x)].pontos.."]"
.."image[1.75,"..(w*0.995-0.05)..";0.66,0.66;xpro_liga_bg.png]"
..liga
.."label[2.4,"..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()
end)

BIN
mods/xpro/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -0,0 +1,4 @@
# Configurações aplicaveis para o menu gráfico

85
mods/xpro/sfinv.lua Normal file
View File

@ -0,0 +1,85 @@
--[[
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 <http://www.gnu.org/licenses/>.
Inventario sfinv
]]
if sfinv == nil then return end
-- Traduções
local S = xpro.S
sfinv.register_page("xpro:info", {
title = S("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 xp_gasto = player:get_attribute("xpro_xp_gasto")
local xp_disp = my_xp-xp_gasto
if xp_disp < 0 then xp_disp = 0 end
-- Calcula progresso da barra
local progresso = 1
if xpro.niveis[my_lvl+1] ~= nil then
local xp = xpro.niveis[my_lvl] - my_xp
local xp_t = xpro.niveis[my_lvl] - xpro.niveis[my_lvl+1]
progresso = xp/xp_t
end
local formspec = "label[0,0;"..S("Nivel @1", my_lvl).."]"
.."label[0,0.5;"..S("Pontos: @1", my_xp).."]"
.."label[0,1;"..S("Cash XP: @1", xp_disp).."]"
.."button[0,1.5;3,1;shop;"..S("Loja de Premios").."]"
.."button[0,2.5;3,1;ranking;"..S("Ranking Global").."]"
-- Liga
.."image[3.8,0.34;4,4;xpro_liga_bg.png]"
.."label[3,0;"..S("Liga @1", xpro.ligas[my_lvl].name).."]"
.."image[4.17,0.7;3.2,3.2;"..xpro.ligas[my_lvl].img.."]"
.."label[0,3.3;"..S("Progresso").."]"
.."image[0,3.8;9.65,0.8;xpro_xp_bar_grade.png^[transformR90^[lowpart:"..math.ceil(progresso*100)..":xpro_xp_bar.png^[transformR270]"
.."image[0,3.8;9.65,0.8;xpro_xp_bar_grade.png]"
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)
elseif fields.shop then
xpro.acessar_shop(player:get_player_name())
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)

139
mods/xpro/shop.lua Normal file
View File

@ -0,0 +1,139 @@
--[[
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 <http://www.gnu.org/licenses/>.
Shopping de XP
]]
-- Traduções
local S = xpro.S
-- Assegurar dados
minetest.register_on_joinplayer(function(player)
if not player:get_attribute("xpro_xp_gasto") then
player:set_attribute("xpro_xp_gasto", 0)
end
end)
-- Controle de acessos
local acessos = {}
minetest.register_on_joinplayer(function(player)
acessos[player:get_player_name()] = {}
end)
minetest.register_on_leaveplayer(function(player)
acessos[player:get_player_name()] = nil
end)
-- Itens a venda
xpro.premios = {}
-- Lista de itens do menu do shop em formato de string
local string_menu_shop = ""
local atualizar_string_menu_shop = function()
string_menu_shop = "" -- zera string
for _,d in pairs(xpro.premios) do
if string_menu_shop ~= "" then string_menu_shop = string_menu_shop .. "," end
string_menu_shop = string_menu_shop .. d.name
end
end
atualizar_string_menu_shop()
-- Acessar shop
xpro.acessar_shop = function(name, aviso)
local player = minetest.get_player_by_name(name)
local acesso = acessos[name]
local xp_gasto = player:get_attribute("xpro_xp_gasto")
local my_xp = xpro.get_player_xp(name)
local xp_disp = my_xp-xp_gasto
if xp_disp < 0 then xp_disp = 0 end
local formspec = "size[8,5]"
..default.gui_bg
..default.gui_bg_img
.."label[0,0;"..S("Loja de Itens por XP").."]"
.."label[0,0.5;"..S("Cash XP: @1", xp_disp).."]"
.."textlist[3.2,0;4.5,5;menu;"..string_menu_shop.."]"
if aviso then
formspec = formspec .. "textarea[0.26,1;3.2,1.2;;"..aviso..";]"
end
-- Nenhum item escolhido
if acesso.escolha == nil then
formspec = formspec .. "label[0,2;"..S("Escolha um Item").."]"
-- Exibir item escolhido
else
local escolha = xpro.premios[acesso.escolha]
formspec = formspec .. "label[0,2;"..S("Custo: @1 CashXP", escolha.custo).."]"
.."label[0,2.5;"..S("Unidades: @1", escolha.qtd).."]"
.."item_image_button[0,3;2.1,2.1;"..escolha.item..";comprar;"..S("Comprar").."]"
end
minetest.show_formspec(name, "xpro:shop", formspec)
end
-- Receber Botoes
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == "xpro:shop" then
-- Escolher um item
if fields.menu then
local name = player:get_player_name()
local n = string.split(fields.menu, ":")
acessos[name].escolha = tonumber(n[2]) or 1
xpro.acessar_shop(name)
-- Comprar
elseif fields.comprar then
local name = player:get_player_name()
local acesso = acessos[name]
local escolha = xpro.premios[acesso.escolha]
local my_xp = xpro.get_player_xp(name)
local xp_gasto = player:get_attribute("xpro_xp_gasto")
local xp_disp = my_xp-xp_gasto
if xp_disp < 0 then xp_disp = 0 end
-- Tenta trocar
if xp_disp < escolha.custo then
xpro.acessar_shop(name, S("Cash XP insuficiente"))
else
if xpro.tror.trocar_plus(player, nil, {escolha.item.." "..escolha.qtd}) == false then
xpro.acessar_shop(name, S("Inventario lotado"))
else
player:set_attribute("xpro_xp_gasto", (xp_gasto+escolha.custo))
xpro.acessar_shop(name, minetest.colorize("#0C0", S("Adiquirido")))
-- Limpa o inventario para exibir novo cash disponivel
if sfinv then
sfinv.set_player_inventory_formspec(minetest.get_player_by_name(name))
end
end
end
end
end
end)
-- Registrar premios
xpro.registrar_premio = function(name, def)
table.insert(xpro.premios,
{
name=name,
item=def.item,
qtd=def.qtd,
custo=def.custo,
}
)
-- Atualiza lista de exibição
atualizar_string_menu_shop()
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -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

27
mods/xpro/tools/xgettext.sh Executable file
View File

@ -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;

183
mods/xpro/tradutor.lua Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
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