update code

master
BrunoMine 2020-04-04 22:27:19 -03:00
parent 5a592a46ed
commit 7b12a16cac
25 changed files with 1280 additions and 95 deletions

1
API.md
View File

@ -52,6 +52,7 @@ Veja os métodos de acordo com sua finalidade.
* `macromoney.register_value(value_id, {definições de valor})`: Register value
#### Manipular valores em contas
* `macromoney.has_amount(player_name, value_id, amount)`: Verifica se possui um montante na conta
* `macromoney.get_account(player_name, value_id)`: Pega um valor em uma conta
* `macromoney.add_account(player_name, value_id, add_value)`: Adiciona um valor em uma conta
* `macromoney.subtract_account(player_name, value_id, subtract_value)`: Subtrai um valor em uma conta

62
aliases.lua Normal file
View File

@ -0,0 +1,62 @@
--[[
Mod Minemacro for Minetest
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Aliases
]]
-- Compatibility with older mods
-- Somar
macromoney.somar = function(name, tipo_v, valor)
if tipo_v ~= "macros" then
minetest.log("error", "[Macromoney] Discontinued method with invalid value (tipo_v ="..dump(tipo_v)..")")
minetest.request_shutdown("Internal error")
return false
end
minetest.log("deprecated", "[Macromoney] Deprecated 'macromoney.somar' method (update code)")
macromoney.add_account(name, "money", valor)
end
-- Subtrair
macromoney.subtrair = function(name, tipo_v, valor, confisco)
if tipo_v ~= "macros" then
minetest.log("error", "[Macromoney] Discontinued method with invalid value (tipo_v ="..dump(tipo_v)..")")
minetest.request_shutdown("Internal error")
return false
end
if confisco ~= nil then
minetest.log("error", "[Macromoney] Discontinued method with invalid value ('confisco' param used)")
minetest.request_shutdown("Internal error")
return false
end
minetest.log("deprecated", "[Macromoney] Deprecated 'macromoney.subtrair' method (update code)")
macromoney.subtract_account(name, "money", valor)
end
-- Consultar
macromoney.consultar = function(name, tipo_v)
if tipo_v ~= "macros" then
minetest.log("error", "[Macromoney] Discontinued method with invalid value (tipo_v ="..dump(tipo_v)..")")
minetest.request_shutdown("Internal error")
return false
end
minetest.log("deprecated", "[Macromoney] Deprecated 'macromoney.consultar' method (update code)")
return macromoney.get_account(name, "money")
end
-- Existe
macromoney.existe = function(name)
minetest.log("deprecated", "[Macromoney] Deprecated 'macromoney.existe' method (update code)")
return macromoney.exist_account(name)
end

113
api.lua
View File

@ -8,54 +8,10 @@
API
]]
-- Basic methods
-- Exists account
macromoney.exist_account = function(name)
return macromoney.db.exist(name)
end
-- Exists account value
macromoney.exist_account_value = function(name, value_type)
local data = macromoney.db.get(name)
if data[value_type] ~= nil then
return true
else
return false
end
end
-- Set
macromoney.set_account = function(name, value_type, new_value)
local data = macromoney.db.get(name)
data[value_type] = new_value
return macromoney.db.set(name, data)
end
-- Get
macromoney.get_account = function(name, value_type)
return macromoney.db.get(name)[value_type]
end
-- Add
macromoney.add_account = function(name, value_type, add_value)
local data = macromoney.db.get(name)
data[value_type] = data[value_type] + add_value
macromoney.db.set(name, data)
end
-- Subtract
macromoney.subtract_account = function(name, value_type, subtract_value)
local data = macromoney.db.get(name)
data[value_type] = data[value_type] - subtract_value
macromoney.db.set(name, data)
end
-- Tags
macromoney.tags = {}
-- Registered values
macromoney.registered_values = {}
@ -69,9 +25,72 @@ macromoney.register_value = function(value_id, def)
end
end
-- Get value ID
macromoney.get_value_id = function(tag_or_id)
if macromoney.tags[tag_or_id] then
return macromoney.tags[tag_or_id]
end
return tag_or_id
end
local get_id = macromoney.get_value_id
-- Basic methods
-- Exists account
macromoney.exist_account = function(name)
return macromoney.db.exist(name)
end
-- Exists account value
macromoney.exist_account_value = function(name, value_id)
local data = macromoney.db.get(name)
if data[get_id(value_id)] ~= nil then
return true
else
return false
end
end
-- Set
macromoney.set_account = function(name, value_id, new_value)
local data = macromoney.db.get(name)
data[get_id(value_id)] = new_value
return macromoney.db.set(name, data)
end
-- Get
macromoney.get_account = function(name, value_id)
return macromoney.db.get(name)[get_id(value_id)]
end
-- Add
macromoney.add_account = function(name, value_id, add_value)
local data = macromoney.db.get(name)
data[get_id(value_id)] = data[get_id(value_id)] + add_value
macromoney.db.set(name, data)
end
-- Subtract
macromoney.subtract_account = function(name, value_id, subtract_value)
local data = macromoney.db.get(name)
data[get_id(value_id)] = data[get_id(value_id)] - subtract_value
macromoney.db.set(name, data)
end
-- Check amount
macromoney.has_amount = function(name, value_id, amount)
local data = macromoney.db.get(name)
if data[get_id(value_id)] >= amount then
return true
end
return false
end
-- Get text value
macromoney.get_text_number_value = function(value_id, value)
local def = macromoney.registered_values[value_id]
macromoney.get_value_to_text = function(value_id, value)
local def = macromoney.registered_values[macromoney.get_value_id(value_id)]
local prefix = def.specimen_prefix or ""
local text
@ -99,6 +118,8 @@ macromoney.get_text_number_value = function(value_id, value)
return text
end
-- Check and register player accounts
minetest.register_on_joinplayer(function(player)
if not player then return end

30
atm.lua
View File

@ -1,18 +1,18 @@
--[[
Mod Macromoney para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Mod Minemacro for Minetest
Copyright (C) 2020 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/>.
Nodes
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
ATM
]]
-- Money machine
local S = macromoney.S
-- ATM
minetest.register_node("macromoney:atm", {
description = "Automatic Teller Machine",
description = S("Automatic Teller Machine"),
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
@ -47,9 +47,9 @@ minetest.register_node("macromoney:atm", {
local formspec = "size[8,5.5;]"
..default.gui_bg
..default.gui_bg_img
.."label[0.256,0;You can deposit or withdraw "..macromoney.get_text_number_value("macromoney:money", 100).."]"
.."button[1,0.5;2,1;withdraw;Withdraw]"
.."button[5,0.5;2,1;deposit;Deposit]"
.."label[0.256,0;"..S("You can deposit or withdraw @1", macromoney.get_value_to_text("macromoney:money", 100)).."]"
.."button[1,0.5;2,1;withdraw;"..S("Withdraw").."]"
.."button[5,0.5;2,1;deposit;"..S("Deposit").."]"
.."list[current_player;main;0,1.5;8,4;]"
minetest.show_formspec(player:get_player_name(), "macromoney:atm", formspec)
@ -67,12 +67,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Check inventory
if not player_inv:room_for_item("main", "macromoney:macro 100") then
minetest.chat_send_player(player_name, "Crowded inventory")
minetest.chat_send_player(player_name, S("Crowded inventory."))
return true
-- Check account balance
elseif macromoney.get_account(player_name, "macromoney:money") < 100 then
minetest.chat_send_player(player_name, "Insufficient balance for this operation.")
minetest.chat_send_player(player_name, S("Account balance is insufficient."))
return true
end
@ -86,7 +86,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Check inventory
if not player_inv:contains_item("main", "macromoney:macro 100") then
minetest.chat_send_player(player_name, "You have enough money in your inventory.")
minetest.chat_send_player(player_name, S("You cashed out @1.", 100))
return true
end

View File

@ -10,11 +10,13 @@
]]
local S = macromoney.S
-- Accounts manager privilege
minetest.register_privilege("macromoney_admin", "Accounts manager")
minetest.register_privilege("macromoney_admin", S("Accounts manager"))
-- Get text number value
local to_text = macromoney.get_text_number_value
local to_text = macromoney.get_value_to_text
-- Send account on chat
local send_acct_on_chat = function(name, acct_name)
@ -29,14 +31,15 @@ end
-- "macromoney" command
minetest.register_chatcommand("macromoney", {
privs = {macromoney_admin = true},
params = "[<account> | <add/subtract/set> <value_id>]",
description = "Manage accounts",
params = S("[<account> | <add/subtract/set> <value_id>]"),
description = S("Manage accounts"),
func = function(name, param)
-- Consult self account
if param == "" then --/macromoney
minetest.chat_send_player(name, "Your account")
minetest.chat_send_player(name, "***** "..S("Your account").." *****")
send_acct_on_chat(name, name)
return true
end
local m = string.split(param, " ")
@ -44,12 +47,12 @@ minetest.register_chatcommand("macromoney", {
-- Check account
if macromoney.exist_account(param1) == false then
return false, "Account not exist."
return false, S("Account not exist.")
end
-- Consultar conta de outro
if param1 and not param2 then --/macromoney <conta>
minetest.chat_send_player(name, param1.." account")
minetest.chat_send_player(name, "*** "..S("@1 account", param1).." ***")
send_acct_on_chat(name, param1)
return
end
@ -63,13 +66,13 @@ minetest.register_chatcommand("macromoney", {
-- Check value id
if macromoney.registered_values[param3] == nil then
return false, "Ivalid value type '"..param3.."'"
return false, S("Ivalid value type '@1'.", param1)
end
-- Check and adjust numeric value
if macromoney.registered_values[param3].value_type == "number" then
if not tonumber(param4) then
return false, "Invalid operation. '"..param3.."' is not numeric value."
return false, S("Invalid operation. '@1' is not numeric value.", param3)
end
param4 = tonumber(param4)
end
@ -79,7 +82,7 @@ minetest.register_chatcommand("macromoney", {
macromoney.subtract_account(param1, param3, param4)
return true, "Subtracted value. New balance is "..to_text(param3, macromoney.get_account(param1, param3))
return true, S("Subtracted value. New balance is @1.", to_text(param3, macromoney.get_account(param1, param3)))
end
-- Add
@ -87,7 +90,7 @@ minetest.register_chatcommand("macromoney", {
macromoney.add_account(param1, param3, param4)
return true, "Added value. New balance is "..to_text(param3, macromoney.get_account(param1, param3))
return true, S("Added value. New balance is @1.", to_text(param3, macromoney.get_account(param1, param3)))
end
-- Set
@ -95,7 +98,7 @@ minetest.register_chatcommand("macromoney", {
macromoney.set_account(param1, param3, param4)
return true, "Setted value. New value is "..to_text(param3, macromoney.get_account(param1, param3))
return true, S("Setted value. New value is @1.", to_text(param3, macromoney.get_account(param1, param3)))
end
end

View File

@ -12,11 +12,14 @@ local modpath = minetest.get_modpath("macromoney")
-- Global table
macromoney = {}
dofile(modpath .. "/translator.lua")
dofile(modpath .. "/data_base.lua")
dofile(modpath .. "/api.lua")
dofile(modpath .. "/commands.lua")
dofile(modpath .. "/aliases.lua")
-- Custom
dofile(modpath .. "/money.lua")
dofile(modpath .. "/safe_box.lua")

45
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

BIN
locale/en.mo Normal file

Binary file not shown.

112
locale/en.po Normal file
View File

@ -0,0 +1,112 @@
# 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: 2020-04-04 22:22-0300\n"
"PO-Revision-Date: 2020-04-04 22:25-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"
#: atm.lua
msgid "Automatic Teller Machine"
msgstr "Automatic Teller Machine"
#: atm.lua
msgid "You can deposit or withdraw @1"
msgstr "You can deposit or withdraw @1"
#: atm.lua
msgid "Withdraw"
msgstr "Withdraw"
#: atm.lua
msgid "Deposit"
msgstr "Deposit"
#: atm.lua
msgid "Crowded inventory."
msgstr "Crowded inventory."
#: atm.lua
msgid "Account balance is insufficient."
msgstr "Account balance is insufficient."
#: atm.lua
msgid "You cashed out @1."
msgstr "You cashed out @1."
#: commands.lua
msgid "Accounts manager"
msgstr "Accounts manager"
#: commands.lua
msgid "[<account> | <add/subtract/set> <value_id>]"
msgstr "[<account> | <add/subtract/set> <value_id>]"
#: commands.lua
msgid "Manage accounts"
msgstr "Manage accounts"
#: commands.lua
msgid "Your account"
msgstr "Your account"
#: commands.lua
msgid "Account not exist."
msgstr "Account not exist."
#: commands.lua
msgid "@1 account"
msgstr "@1 account"
#: commands.lua
msgid "Ivalid value type '@1'."
msgstr "Ivalid value type '@1'."
#: commands.lua
msgid "Invalid operation. '@1' is not numeric value."
msgstr "Invalid operation. '@1' is not numeric value."
#: commands.lua
msgid "Subtracted value. New balance is @1."
msgstr "Subtracted value. New balance is @1."
#: commands.lua
msgid "Added value. New balance is @1."
msgstr "Added value. New balance is @1."
#: commands.lua
msgid "Setted value. New value is @1."
msgstr "Setted value. New value is @1."
#: money.lua
msgid "Macro money"
msgstr "Macro money"
#: money.lua
msgid "Macro"
msgstr "Macro"
#: money.lua
msgid "Suitcase of Macros"
msgstr "Suitcase of Macros"
#: safe_box.lua
msgid "Safe Box"
msgstr "Safe Box"
#~ msgid "Insufficient balance for this operation."
#~ msgstr "Insufficient balance for this operation."
#~ msgid "You have enough money in your inventory."
#~ msgstr "You have enough money in your inventory."

106
locale/en.po~ Normal file
View File

@ -0,0 +1,106 @@
# 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: 2020-04-04 21:27-0300\n"
"PO-Revision-Date: 2020-04-04 21:28-0300\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.0.6\n"
#: atm.lua
msgid "Automatic Teller Machine"
msgstr "Automatic Teller Machine"
#: atm.lua
msgid "You can deposit or withdraw @1"
msgstr "You can deposit or withdraw @1"
#: atm.lua
msgid "Withdraw"
msgstr "Withdraw"
#: atm.lua
msgid "Deposit"
msgstr "Deposit"
#: atm.lua
msgid "Crowded inventory."
msgstr "Crowded inventory."
#: atm.lua
msgid "Insufficient balance for this operation."
msgstr "Insufficient balance for this operation."
#: atm.lua
msgid "You have enough money in your inventory."
msgstr "You have enough money in your inventory."
#: commands.lua
msgid "Accounts manager"
msgstr "Accounts manager"
#: commands.lua
msgid "[<account> | <add/subtract/set> <value_id>]"
msgstr "[<account> | <add/subtract/set> <value_id>]"
#: commands.lua
msgid "Manage accounts"
msgstr "Manage accounts"
#: commands.lua
msgid "Your account"
msgstr "Your account"
#: commands.lua
msgid "Account not exist."
msgstr "Account not exist."
#: commands.lua
msgid "@1 account"
msgstr "@1 account"
#: commands.lua
msgid "Ivalid value type '@1'."
msgstr "Ivalid value type '@1'."
#: commands.lua
msgid "Invalid operation. '@1' is not numeric value."
msgstr "Invalid operation. '@1' is not numeric value."
#: commands.lua
msgid "Subtracted value. New balance is @1."
msgstr "Subtracted value. New balance is @1."
#: commands.lua
msgid "Added value. New balance is @1."
msgstr "Added value. New balance is @1."
#: commands.lua
msgid "Setted value. New value is @1."
msgstr "Setted value. New value is @1."
#: money.lua
msgid "Macro money"
msgstr "Macro money"
#: money.lua
msgid "Macro"
msgstr "Macro"
#: money.lua
msgid "Suitcase of Macros"
msgstr "Suitcase of Macros"
#: safe_box.lua
msgid "Safe Box"
msgstr "Safe Box"

24
locale/macromoney.en.tr Normal file
View File

@ -0,0 +1,24 @@
### Arquivo gerado por macromoney apartir de en.po
# textdomain: macromoney
Manage accounts=Manage accounts
Setted value. New value is @1.=Setted value. New value is @1.
Automatic Teller Machine=Automatic Teller Machine
You can deposit or withdraw @1=You can deposit or withdraw @1
Withdraw=Withdraw
Macro money=Macro money
You cashed out @1.=You cashed out @1.
Subtracted value. New balance is @1.=Subtracted value. New balance is @1.
Your account=Your account
Account balance is insufficient.=Account balance is insufficient.
Macro=Macro
Deposit=Deposit
[<account> | <add/subtract/set> <value_id>]=[<account> | <add/subtract/set> <value_id>]
Account not exist.=Account not exist.
Crowded inventory.=Crowded inventory.
Ivalid value type '@1'.=Ivalid value type '@1'.
@1 account=@1 account
Invalid operation. '@1' is not numeric value.=Invalid operation. '@1' is not numeric value.
Accounts manager=Accounts manager
Suitcase of Macros=Suitcase of Macros
Added value. New balance is @1.=Added value. New balance is @1.
Safe Box=Safe Box

24
locale/macromoney.pt.tr Normal file
View File

@ -0,0 +1,24 @@
### Arquivo gerado por macromoney apartir de pt.po
# textdomain: macromoney
Manage accounts=Gerenciar contas
Setted value. New value is @1.=Valor definido. O novo saldo é @1.
Automatic Teller Machine=Caixa de Autoatendimento
You can deposit or withdraw @1=Você pode depositar ou sacar @1
Withdraw=Sacar
Macro money=Dinheiro Macro
You cashed out @1.=Você sacou @1.
Subtracted value. New balance is @1.=Valor subtraído. Novo saldo é @1.
Your account=Sua conta
Account balance is insufficient.=O saldo da conta é insuficiente.
Macro=Macro
Deposit=Depositar
[<account> | <add/subtract/set> <value_id>]=[<conta> | <add/subtract/set> <ID_do_valor>]
Account not exist.=Conta inexistente.
Crowded inventory.=Inventário lotado.
Ivalid value type '@1'.=Tipo de valor inválido '@1'.
@1 account=Conta @1
Invalid operation. '@1' is not numeric value.=Operação inválida. '@1' não é um valor numérico.
Accounts manager=Gerenciador de contas
Suitcase of Macros=Maleta de Macros
Added value. New balance is @1.=Valor adicionado. Novo saldo é @1.
Safe Box=Cofre

BIN
locale/pt.mo Normal file

Binary file not shown.

112
locale/pt.po Normal file
View File

@ -0,0 +1,112 @@
# 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: 2020-04-04 22:22-0300\n"
"PO-Revision-Date: 2020-04-04 22:23-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"
#: atm.lua
msgid "Automatic Teller Machine"
msgstr "Caixa de Autoatendimento"
#: atm.lua
msgid "You can deposit or withdraw @1"
msgstr "Você pode depositar ou sacar @1"
#: atm.lua
msgid "Withdraw"
msgstr "Sacar"
#: atm.lua
msgid "Deposit"
msgstr "Depositar"
#: atm.lua
msgid "Crowded inventory."
msgstr "Inventário lotado."
#: atm.lua
msgid "Account balance is insufficient."
msgstr "O saldo da conta é insuficiente."
#: atm.lua
msgid "You cashed out @1."
msgstr "Você sacou @1."
#: commands.lua
msgid "Accounts manager"
msgstr "Gerenciador de contas"
#: commands.lua
msgid "[<account> | <add/subtract/set> <value_id>]"
msgstr "[<conta> | <add/subtract/set> <ID_do_valor>]"
#: commands.lua
msgid "Manage accounts"
msgstr "Gerenciar contas"
#: commands.lua
msgid "Your account"
msgstr "Sua conta"
#: commands.lua
msgid "Account not exist."
msgstr "Conta inexistente."
#: commands.lua
msgid "@1 account"
msgstr "Conta @1"
#: commands.lua
msgid "Ivalid value type '@1'."
msgstr "Tipo de valor inválido '@1'."
#: commands.lua
msgid "Invalid operation. '@1' is not numeric value."
msgstr "Operação inválida. '@1' não é um valor numérico."
#: commands.lua
msgid "Subtracted value. New balance is @1."
msgstr "Valor subtraído. Novo saldo é @1."
#: commands.lua
msgid "Added value. New balance is @1."
msgstr "Valor adicionado. Novo saldo é @1."
#: commands.lua
msgid "Setted value. New value is @1."
msgstr "Valor definido. O novo saldo é @1."
#: money.lua
msgid "Macro money"
msgstr "Dinheiro Macro"
#: money.lua
msgid "Macro"
msgstr "Macro"
#: money.lua
msgid "Suitcase of Macros"
msgstr "Maleta de Macros"
#: safe_box.lua
msgid "Safe Box"
msgstr "Cofre"
#~ msgid "Insufficient balance for this operation."
#~ msgstr "Saldo insuficiente para essa operação."
#~ msgid "You have enough money in your inventory."
#~ msgstr "Você não tem dinheiro suficiente em seu inventário."

106
locale/pt.po~ Normal file
View File

@ -0,0 +1,106 @@
# 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: 2020-04-04 21:27-0300\n"
"PO-Revision-Date: 2020-04-04 21:37-0300\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.0.6\n"
#: atm.lua
msgid "Automatic Teller Machine"
msgstr "Caixa de Autoatendimento"
#: atm.lua
msgid "You can deposit or withdraw @1"
msgstr "Você pode depositar ou sacar @1"
#: atm.lua
msgid "Withdraw"
msgstr "Sacar"
#: atm.lua
msgid "Deposit"
msgstr "Depositar"
#: atm.lua
msgid "Crowded inventory."
msgstr "Inventário lotado."
#: atm.lua
msgid "Insufficient balance for this operation."
msgstr "Saldo insuficiente para essa operação."
#: atm.lua
msgid "You have enough money in your inventory."
msgstr "Você não tem dinheiro suficiente em seu inventário."
#: commands.lua
msgid "Accounts manager"
msgstr "Gerenciador de contas"
#: commands.lua
msgid "[<account> | <add/subtract/set> <value_id>]"
msgstr "[<conta> | <add/subtract/set> <ID_do_valor>]"
#: commands.lua
msgid "Manage accounts"
msgstr "Gerenciar contas"
#: commands.lua
msgid "Your account"
msgstr "Sua conta"
#: commands.lua
msgid "Account not exist."
msgstr "Conta inexistente."
#: commands.lua
msgid "@1 account"
msgstr "Conta @1"
#: commands.lua
msgid "Ivalid value type '@1'."
msgstr "Tipo de valor inválido '@1'."
#: commands.lua
msgid "Invalid operation. '@1' is not numeric value."
msgstr "Operação inválida. '@1' não é um valor numérico."
#: commands.lua
msgid "Subtracted value. New balance is @1."
msgstr "Valor subtraído. Novo saldo é @1."
#: commands.lua
msgid "Added value. New balance is @1."
msgstr "Valor adicionado. Novo saldo é @1."
#: commands.lua
msgid "Setted value. New value is @1."
msgstr "Valor definido. O novo saldo é @1."
#: money.lua
msgid "Macro money"
msgstr "Dinheiro Macro"
#: money.lua
msgid "Macro"
msgstr "Macro"
#: money.lua
msgid "Suitcase of Macros"
msgstr "Maleta de Macros"
#: safe_box.lua
msgid "Safe Box"
msgstr "Cofre"

112
locale/pt_BR.po Normal file
View File

@ -0,0 +1,112 @@
# 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: 2020-04-04 22:22-0300\n"
"PO-Revision-Date: 2020-04-04 22:23-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"
#: atm.lua
msgid "Automatic Teller Machine"
msgstr "Caixa de Autoatendimento"
#: atm.lua
msgid "You can deposit or withdraw @1"
msgstr "Você pode depositar ou sacar @1"
#: atm.lua
msgid "Withdraw"
msgstr "Sacar"
#: atm.lua
msgid "Deposit"
msgstr "Depositar"
#: atm.lua
msgid "Crowded inventory."
msgstr "Inventário lotado."
#: atm.lua
msgid "Account balance is insufficient."
msgstr "O saldo da conta é insuficiente."
#: atm.lua
msgid "You cashed out @1."
msgstr "Você sacou @1."
#: commands.lua
msgid "Accounts manager"
msgstr "Gerenciador de contas"
#: commands.lua
msgid "[<account> | <add/subtract/set> <value_id>]"
msgstr "[<conta> | <add/subtract/set> <ID_do_valor>]"
#: commands.lua
msgid "Manage accounts"
msgstr "Gerenciar contas"
#: commands.lua
msgid "Your account"
msgstr "Sua conta"
#: commands.lua
msgid "Account not exist."
msgstr "Conta inexistente."
#: commands.lua
msgid "@1 account"
msgstr "Conta @1"
#: commands.lua
msgid "Ivalid value type '@1'."
msgstr "Tipo de valor inválido '@1'."
#: commands.lua
msgid "Invalid operation. '@1' is not numeric value."
msgstr "Operação inválida. '@1' não é um valor numérico."
#: commands.lua
msgid "Subtracted value. New balance is @1."
msgstr "Valor subtraído. Novo saldo é @1."
#: commands.lua
msgid "Added value. New balance is @1."
msgstr "Valor adicionado. Novo saldo é @1."
#: commands.lua
msgid "Setted value. New value is @1."
msgstr "Valor definido. O novo saldo é @1."
#: money.lua
msgid "Macro money"
msgstr "Dinheiro Macro"
#: money.lua
msgid "Macro"
msgstr "Macro"
#: money.lua
msgid "Suitcase of Macros"
msgstr "Maleta de Macros"
#: safe_box.lua
msgid "Safe Box"
msgstr "Cofre"
#~ msgid "Insufficient balance for this operation."
#~ msgstr "Saldo insuficiente para essa operação."
#~ msgid "You have enough money in your inventory."
#~ msgstr "Você não tem dinheiro suficiente em seu inventário."

112
locale/pt_PT.po Normal file
View File

@ -0,0 +1,112 @@
# 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: 2020-04-04 22:22-0300\n"
"PO-Revision-Date: 2020-04-04 22:23-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"
#: atm.lua
msgid "Automatic Teller Machine"
msgstr "Caixa de Autoatendimento"
#: atm.lua
msgid "You can deposit or withdraw @1"
msgstr "Você pode depositar ou sacar @1"
#: atm.lua
msgid "Withdraw"
msgstr "Sacar"
#: atm.lua
msgid "Deposit"
msgstr "Depositar"
#: atm.lua
msgid "Crowded inventory."
msgstr "Inventário lotado."
#: atm.lua
msgid "Account balance is insufficient."
msgstr "O saldo da conta é insuficiente."
#: atm.lua
msgid "You cashed out @1."
msgstr "Você sacou @1."
#: commands.lua
msgid "Accounts manager"
msgstr "Gerenciador de contas"
#: commands.lua
msgid "[<account> | <add/subtract/set> <value_id>]"
msgstr "[<conta> | <add/subtract/set> <ID_do_valor>]"
#: commands.lua
msgid "Manage accounts"
msgstr "Gerenciar contas"
#: commands.lua
msgid "Your account"
msgstr "Sua conta"
#: commands.lua
msgid "Account not exist."
msgstr "Conta inexistente."
#: commands.lua
msgid "@1 account"
msgstr "Conta @1"
#: commands.lua
msgid "Ivalid value type '@1'."
msgstr "Tipo de valor inválido '@1'."
#: commands.lua
msgid "Invalid operation. '@1' is not numeric value."
msgstr "Operação inválida. '@1' não é um valor numérico."
#: commands.lua
msgid "Subtracted value. New balance is @1."
msgstr "Valor subtraído. Novo saldo é @1."
#: commands.lua
msgid "Added value. New balance is @1."
msgstr "Valor adicionado. Novo saldo é @1."
#: commands.lua
msgid "Setted value. New value is @1."
msgstr "Valor definido. O novo saldo é @1."
#: money.lua
msgid "Macro money"
msgstr "Dinheiro Macro"
#: money.lua
msgid "Macro"
msgstr "Macro"
#: money.lua
msgid "Suitcase of Macros"
msgstr "Maleta de Macros"
#: safe_box.lua
msgid "Safe Box"
msgstr "Cofre"
#~ msgid "Insufficient balance for this operation."
#~ msgstr "Saldo insuficiente para essa operação."
#~ msgid "You have enough money in your inventory."
#~ msgstr "Você não tem dinheiro suficiente em seu inventário."

106
locale/template.pot Normal file
View File

@ -0,0 +1,106 @@
# 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: 2020-04-04 22:24-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"
#: atm.lua
msgid "Automatic Teller Machine"
msgstr ""
#: atm.lua
msgid "You can deposit or withdraw @1"
msgstr ""
#: atm.lua
msgid "Withdraw"
msgstr ""
#: atm.lua
msgid "Deposit"
msgstr ""
#: atm.lua
msgid "Crowded inventory."
msgstr ""
#: atm.lua
msgid "Account balance is insufficient."
msgstr ""
#: atm.lua
msgid "You cashed out @1."
msgstr ""
#: commands.lua
msgid "Accounts manager"
msgstr ""
#: commands.lua
msgid "[<account> | <add/subtract/set> <value_id>]"
msgstr ""
#: commands.lua
msgid "Manage accounts"
msgstr ""
#: commands.lua
msgid "Your account"
msgstr ""
#: commands.lua
msgid "Account not exist."
msgstr ""
#: commands.lua
msgid "@1 account"
msgstr ""
#: commands.lua
msgid "Ivalid value type '@1'."
msgstr ""
#: commands.lua
msgid "Invalid operation. '@1' is not numeric value."
msgstr ""
#: commands.lua
msgid "Subtracted value. New balance is @1."
msgstr ""
#: commands.lua
msgid "Added value. New balance is @1."
msgstr ""
#: commands.lua
msgid "Setted value. New value is @1."
msgstr ""
#: money.lua
msgid "Macro money"
msgstr ""
#: money.lua
msgid "Macro"
msgstr ""
#: money.lua
msgid "Suitcase of Macros"
msgstr ""
#: safe_box.lua
msgid "Safe Box"
msgstr ""

1
locale/translate files Normal file
View File

@ -0,0 +1 @@
atm.lua commands.lua money.lua safe_box.lua

View File

@ -1,18 +1,18 @@
--[[
Mod Macromoney para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Mod Minemacro for Minetest
Copyright (C) 2020 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/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Macros
]]
local S = macromoney.S
-- Register macro money
macromoney.register_value("macromoney:money", {
description = "Macro money",
description = S("Macro money"),
specimen_prefix = "",
value_type = "number",
initial_value = 0,
@ -21,22 +21,21 @@ macromoney.register_value("macromoney:money", {
-- Macro
minetest.register_craftitem("macromoney:macro", {
description = "Macro",
description = S("Macro"),
inventory_image = "macromoney_macro.png",
stack_max = 100,
})
-- Maleta de Macros
minetest.register_craftitem("macromoney:maleta_de_macros", {
description = "Maleta de Macros",
inventory_image = "macromoney_maleta_de_macros.png",
-- Suitcase of Macros
minetest.register_craftitem("macromoney:suitcase_of_macros", {
description = S("Suitcase of Macros"),
inventory_image = "macromoney_suitcase_of_macros.png",
stack_max = 5,
})
-- Maleta de Macros
minetest.register_craft({
output = "macromoney:macro 100",
recipe = {
{"macromoney:maleta_de_macros"},
{"macromoney:suitcase_of_macros"},
}
})

View File

@ -1,15 +1,15 @@
--[[
Mod Macromoney para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Mod Minemacro for Minetest
Copyright (C) 2020 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/>.
Cofre
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Safe Box
]]
local S = macromoney.S
function default.get_safe_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec =
@ -27,7 +27,7 @@ local function has_safe_privilege(meta, player)
end
minetest.register_node("macromoney:safe_box", {
description = "Safe Box",
description = S("Safe Box"),
paramtype = "light",
paramtype2 = "facedir",
tiles = {"macromoney_safe_box_side.png",

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

33
tools/xgettext.bat Normal file
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
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;

176
translator.lua Normal file
View File

@ -0,0 +1,176 @@
--[[
Mod Macromoney for Minetest
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Translator
]]
-- Modpath
local modpath = minetest.get_modpath("macromoney")
-- Tradução intllib
macromoney.intllib = {}
macromoney.intllib.S, macromoney.intllib.NS = dofile(modpath.."/lib/intllib.lua")
-- Configura tradutor opicional
macromoney.S = macromoney.intllib.S
macromoney.NS = macromoney.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 macromoney.*.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 macromoney apartir de "..file.."\n# textdomain: macromoney\n"
for en,lang in pairs(en_to_lang) do
new_file = new_file .. en .. "=" .. lang .. "\n"
end
-- Escrever arquivo
local saida = io.open(modpath.."/locale/macromoney."..lang_code..".tr", "w")
saida:write(new_file)
io.close(saida)
end
end
end
end
-- Ajuste para repassar termos em ingles
local s
if minetest.get_translator ~= nil then
s = minetest.get_translator("macromoney")
else
s = macromoney.intllib.S
end
macromoney.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", "[macromoney] 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
macromoney.s = s
end
macromoney.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, macromoney.S(a))
else
table.insert(r, a)
end
end
return macromoney.s(unpack(r))
elseif type(args[1]) == "string" then
-- Não traduz caso faltem argumentos (devido strings ilustrativas)
return macromoney.s(...)
else
return args[1]
end
end
-- Função que retorna a string inalterada para passar pela checagem
macromoney.Sfake = function(s) return s end