Added support for localization

master
h4ml3t 2019-12-01 14:56:43 +01:00
parent 441019f3c3
commit 0aee054523
No known key found for this signature in database
GPG Key ID: 271F8A06F0612005
7 changed files with 137 additions and 98 deletions

9
locale/hardtorch.it.tr Normal file
View File

@ -0,0 +1,9 @@
# textdomain:hardtorch
Oil=Olio
Without fuel=Senza combustibile
Without heat source or lighter=Senza fonte di calore o acciarino
Torch (used)=Torcia (usata)
Oil Lamp=Lampada a olio
Oil Lamp Lit=Lampada a olio accesa
Candle (used)=Candela (usata)

9
locale/template.txt Normal file
View File

@ -0,0 +1,9 @@
# textdomain:hardtorch
Oil=
Without fuel=
Without heat source or lighter=
Torch (used)=
Oil Lamp=
Oil Lamp Lit=
Candle (used)=

16
oil.lua
View File

@ -1,25 +1,29 @@
--[[
Mod HardTorch 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/>.
se não, veja em <http://www.gnu.org/licenses/>.
Registro de Oleo
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Noites de durabilidade da tocha da lamparina
local oil_nights = math.abs(tonumber(minetest.settings:get("hardtorch_oil_nights") or 1.2))
local oil_nights = math.abs(tonumber(minetest.settings:get("hardtorch_oil_nights") or 1.2))
if oil_nights <= 0 then oil_nights = 1.2 end
-- Oleo de lamparina
minetest.register_tool("hardtorch:oil", {
description = "Oil",
description = S("Oil"),
inventory_image = "hardtorch_oil.png",
})

136
tool.lua
View File

@ -1,24 +1,28 @@
--[[
Mod HardTorch 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/>.
se não, veja em <http://www.gnu.org/licenses/>.
Ferramentas
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Acender tocha
hardtorch.acender_tocha = function(itemstack, player)
local name = player:get_player_name()
local torchname = itemstack:get_name()
itemstack:set_name(torchname.."_on")
-- Verifica se ja esta acessa (evitar loop duplo)
if not hardtorch.em_loop[name] then
if not hardtorch.em_loop[name] then
hardtorch.em_loop[name] = {
lpos = hardtorch.get_lpos(player),
torchname = torchname,
@ -32,7 +36,7 @@ hardtorch.acender_tocha = function(itemstack, player)
-- Som
hardtorch.som_acender(player:getpos(), torchname)
end
return itemstack
end
@ -41,16 +45,16 @@ end
hardtorch.apagar_tocha = function(player, torchname)
-- Remover luz do hud
hardtorch.remover_luz_hud(player)
local loop = hardtorch.em_loop[player:get_player_name()]
torchname = torchname or loop.torchname
-- Pega a tocha
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
if list then
local inv = player:get_inventory()
-- Coloca no lugar
-- Coloca no lugar
itemstack:set_name(torchname)
inv:set_stack(list, i, itemstack)
end
@ -64,10 +68,10 @@ hardtorch.loop_tocha = function(name, torchname)
-- Verifica jogador
local player = minetest.get_player_by_name(name)
if not player then end
local def = hardtorch.registered_torchs[torchname]
local loop = hardtorch.em_loop[name]
-- Verifica tocha
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
if not itemstack then
@ -76,19 +80,19 @@ hardtorch.loop_tocha = function(name, torchname)
hardtorch.em_loop[name] = nil
return
end
-- Verifica se tem lugar para a luz
do
do
local nn = minetest.get_node(hardtorch.get_lpos(player)).name
if nn ~= "air" and not string.match(nn, "hardtorch:luz_") then
-- Encerra loop
hardtorch.apagar_tocha(player, torchname)
hardtorch.em_loop[name] = nil
return
end
end
end
-- Combustivel
-- Atualiza combustivel em uso
local inv = player:get_inventory()
@ -98,7 +102,7 @@ hardtorch.loop_tocha = function(name, torchname)
loop.fuel = nil
else
loop.fuel = {list=listfuel, i=indexfuel, name=itemfuel:get_name()}
end
end
end
-- Consome o Combustivel
if loop.fuel then
@ -108,15 +112,15 @@ hardtorch.loop_tocha = function(name, torchname)
else
-- Aviso de "sem combustivel"
if torchname ~= def.fuel[1] then
minetest.chat_send_player(player:get_player_name(), "Sem combustivel")
minetest.chat_send_player(player:get_player_name(), S("Without fuel"))
end
-- Encerra loop
hardtorch.apagar_tocha(player, torchname)
hardtorch.em_loop[name] = nil
return
end
-- Verifica se acabou a tocha durante o loop
if itemstack:is_empty() then
-- Encerra loop
@ -124,16 +128,16 @@ hardtorch.loop_tocha = function(name, torchname)
hardtorch.em_loop[name] = nil
return
end
-- Verifica se luz do hud foi criada
if not loop.hud_id
if not loop.hud_id
or not player:hud_get(loop.hud_id)
then
hardtorch.adicionar_luz_hud(player, torchname)
end
-- Prepara para proximo loop
minetest.after(2, hardtorch.loop_tocha, name, torchname)
end
@ -141,21 +145,21 @@ end
-- Registra as ferramentas
hardtorch.register_tool = function(torchname, def)
-- Ajusta a ferramenta criada
minetest.override_item(torchname, {
on_use = function(itemstack, user, pointed_thing)
if itemstack:get_name() ~= torchname then return end
-- Verifica se ja tem uma tocha acessa
if hardtorch.em_loop[user:get_player_name()] then
return
end
-- Verifica se tem fonte de fogo
if hardtorch.torch_lighter then
if pointed_thing.under and hardtorch.fontes_de_fogo[minetest.get_node(pointed_thing.under).name]
or pointed_thing.above and hardtorch.fontes_de_fogo[minetest.get_node(pointed_thing.above).name]
if pointed_thing.under and hardtorch.fontes_de_fogo[minetest.get_node(pointed_thing.under).name]
or pointed_thing.above and hardtorch.fontes_de_fogo[minetest.get_node(pointed_thing.above).name]
then
return hardtorch.acender_tocha(itemstack, user)
end
@ -167,7 +171,7 @@ hardtorch.register_tool = function(torchname, def)
return hardtorch.acender_tocha(itemstack, user)
end
end
minetest.chat_send_player(user:get_player_name(), "Sem fonte de calor ou acendedor")
minetest.chat_send_player(user:get_player_name(), S("Without heat source or lighter"))
return itemstack
end
return hardtorch.acender_tocha(itemstack, user)
@ -184,13 +188,13 @@ hardtorch.register_tool = function(torchname, def)
end
end
end
if itemstack:get_name() ~= torchname then return end
if pointed_thing.type ~= "node" then
return itemstack
end
-- Verifica se esta acessando outro node
local under = pointed_thing.under
local node = minetest.get_node(under)
@ -200,17 +204,17 @@ hardtorch.register_tool = function(torchname, def)
return defnode.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
-- Verifica se tem algum impedimento no local
if hardtorch.check_torch_area(pointed_thing.above) == false then
return itemstack
end
-- Verificar se é um node
if not minetest.registered_nodes[torchname] then
return itemstack
end
-- Definir node de acordo com posicionamento
local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
@ -221,7 +225,7 @@ hardtorch.register_tool = function(torchname, def)
else
itemstack:set_name(def.nodes.node_wall or def.nodes.node)
end
-- Coloca node apagado
if hardtorch.registered_torchs[torchname].nodes_off then
itemstack:set_name(hardtorch.registered_torchs[torchname].nodes_off.node)
@ -229,22 +233,22 @@ hardtorch.register_tool = function(torchname, def)
if not minetest.item_place(itemstack, placer, pointed_thing) then
return itemstack
end
-- Remove item do inventario
itemstack:take_item()
return itemstack
end,
})
-- Versao acessa
minetest.override_item(torchname.."_on", {
wield_image = "hardtorch_torch_tool_on_mao.png",
on_use = function(itemstack, user, pointed_thing)
-- Verifica se node acerta tem interação
local under = pointed_thing.under
if under then
@ -257,34 +261,34 @@ hardtorch.register_tool = function(torchname, def)
pointed_thing) or itemstack
end
end
if itemstack:get_name() ~= torchname.."_on" then return end
-- Remover luz
hardtorch.som_apagar(user:getpos(), torchname)
hardtorch.apagar_node_luz(user:get_player_name())
hardtorch.remover_luz_hud(user)
itemstack:set_name(torchname)
return itemstack
end,
on_drop = function(itemstack, dropper, pos)
if itemstack:get_name() ~= torchname.."_on" then return end
-- Remover luz
hardtorch.apagar_node_luz(dropper:get_player_name())
hardtorch.remover_luz_hud(dropper)
itemstack:set_name(torchname)
minetest.item_drop(itemstack, dropper, pos)
itemstack:clear()
return itemstack
end,
-- Ao colocar funciona como tocha normal apenas repassando o desgaste
on_place = function(itemstack, placer, pointed_thing)
-- Verifica nodes evitaveis
if pointed_thing.under and hardtorch.evitar_tool_on_place[1] then
local nn = minetest.get_node(pointed_thing.under).name
@ -294,13 +298,13 @@ hardtorch.register_tool = function(torchname, def)
end
end
end
if itemstack:get_name() ~= torchname.."_on" then return end
if pointed_thing.type ~= "node" then
return itemstack
end
-- Verifica se esta acessando outro node
local under = pointed_thing.under
local node = minetest.get_node(under)
@ -310,25 +314,25 @@ hardtorch.register_tool = function(torchname, def)
return defnode.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
-- Verifica se ja iniciou loop
local loop = hardtorch.em_loop[placer:get_player_name()]
if not loop then
return itemstack
end
-- Verifica se tem combustivel
local inv = placer:get_inventory()
if not loop or not loop.fuel or inv:get_stack(loop.fuel.list, loop.fuel.i):get_name() ~= loop.fuel.name then
return itemstack
end
-- Verifica se tem algum impedimento no local
if hardtorch.check_torch_area(pointed_thing.above) == false then
return itemstack
end
-- Definir node de acordo com posicionamento
local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
@ -341,11 +345,11 @@ hardtorch.register_tool = function(torchname, def)
end
itemstack = minetest.item_place(itemstack, placer, pointed_thing, wdir)
if not itemstack then
return
end
-- Repassa desgaste de combustivel
local fuelname, fuelwear
fuelname = loop.fuel.name
@ -359,18 +363,18 @@ hardtorch.register_tool = function(torchname, def)
meta:set_string("hardtorch_fuel", fuelname)
meta:set_int("hardtorch_wear", fuelwear)
minetest.get_node_timer(pointed_thing.above):start(hardtorch.get_node_timeout(pointed_thing.above))
-- Remove item do inventario
itemstack:take_item()
-- Remover luz
hardtorch.apagar_node_luz(placer:get_player_name())
hardtorch.remover_luz_hud(placer)
return itemstack
end,
})
end
-- Apaga tocha da mão quando o jogador desconecta

View File

@ -1,15 +1,19 @@
--[[
Mod HardTorch 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/>.
se não, veja em <http://www.gnu.org/licenses/>.
Registro de Lamparina
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Luminosidade da lamparina
local lamp_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_lamp_light_source") or 13)
@ -62,7 +66,7 @@ local node_nodebox = {
-- Register node de lamparina
local def_lamp = minetest.serialize({
description = "Oil Lamp",
description = S("Oil Lamp"),
stack_max = 1,
tiles = {
"hardtorch_lamp_wield_cima.png",
@ -89,22 +93,22 @@ local def_lamp = minetest.serialize({
minetest.register_node("hardtorch:lamp", minetest.deserialize(def_lamp))
minetest.override_item("hardtorch:lamp", {
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
itemstack:set_name("hardtorch:lamp_node")
if not minetest.item_place(itemstack, placer, pointed_thing) then
return itemstack
end
-- Remove item do inventario
itemstack:take_item()
return itemstack
end,
})
@ -112,7 +116,7 @@ minetest.override_item("hardtorch:lamp", {
-- Node-ferramenta ativo
minetest.register_node("hardtorch:lamp_on", minetest.deserialize(def_lamp))
minetest.override_item("hardtorch:lamp_on", {
description = "Oil Lamp Lit",
description = S("Oil Lamp Lit"),
paramtype = "light",
paramtype = nil,
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
@ -126,7 +130,7 @@ minetest.override_item("hardtorch:lamp_on", {
},
})
-- Node
-- Node
minetest.register_node("hardtorch:lamp_node", minetest.deserialize(def_lamp))
minetest.override_item("hardtorch:lamp_node", {
drop = "hardtorch:lamp",

View File

@ -1,19 +1,24 @@
--[[
Mod HardTorch 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/>.
se não, veja em <http://www.gnu.org/licenses/>.
Registro de Tochas padrao
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Luminosidade da lamparina
local torch_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_torch_light_source") or 11)
local torch_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_torch_light_source") or 11)
-- Noites de durabilidade da tocha
local torch_nights = math.abs(tonumber(minetest.settings:get("hardtorch_torch_nights") or 0.1))
local torch_nights = math.abs(tonumber(minetest.settings:get("hardtorch_torch_nights") or 0.1))
if torch_nights <= 0 then torch_nights = 0.1 end
@ -35,7 +40,7 @@ hardtorch.register_fuel("hardtorch:torch_on", {
-- Registrar ferramentas
minetest.register_tool("hardtorch:torch", {
description = "Torch (used)",
description = S("Torch (used)"),
inventory_image = "hardtorch_torch_tool_off.png",
wield_image = "hardtorch_torch_tool_off.png",
groups = {not_in_creative_inventory = 1},
@ -53,8 +58,8 @@ hardtorch.register_torch("hardtorch:torch", {
light_source = minetest.registered_nodes["default:torch"].light_source,
fuel = {"hardtorch:torch_on"},
nodes = {
node = "default:torch",
node_ceiling = "default:torch_ceiling",
node = "default:torch",
node_ceiling = "default:torch_ceiling",
node_wall = "default:torch_wall"
},
sounds = {

View File

@ -1,21 +1,25 @@
--[[
Mod HardTorch para Minetest
Copyright (C) 2019 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/>.
se não, veja em <http://www.gnu.org/licenses/>.
Registro de Vela (candle) do mod xdecor
]]
if minetest.registered_nodes["xdecor:candle"] == nil then return end
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Luminosidade da lamparina
local candle_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_xdecor_candle_light_source") or 7)
local candle_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_xdecor_candle_light_source") or 7)
-- Noites de durabilidade da tocha
local candle_nights = math.abs(tonumber(minetest.settings:get("hardtorch_xdecor_candle_nights") or 0.8))
local candle_nights = math.abs(tonumber(minetest.settings:get("hardtorch_xdecor_candle_nights") or 0.8))
if candle_nights <= 0 then candle_nights = 0.8 end
@ -37,7 +41,7 @@ hardtorch.register_fuel("hardtorch:xdecor_candle_on", {
-- Registrar ferramentas
minetest.register_tool("hardtorch:xdecor_candle", {
description = "Candle (used)",
description = S("Candle (used)"),
inventory_image = "xdecor_candle_wield.png",
wield_image = "xdecor_candle_wield.png",
groups = {not_in_creative_inventory = 1},
@ -55,8 +59,8 @@ hardtorch.register_torch("hardtorch:xdecor_candle", {
light_source = minetest.registered_nodes["xdecor:candle"].light_source,
fuel = {"hardtorch:xdecor_candle_on"},
nodes = {
node = "xdecor:candle",
node_ceiling = "xdecor:candle",
node = "xdecor:candle",
node_ceiling = "xdecor:candle",
node_wall = "xdecor:candle"
},
sounds = {