Code internationalization

All code
master
BrunoMine 2019-12-02 14:12:11 -03:00
parent 1ff877094a
commit f47479a6cb
37 changed files with 701 additions and 513 deletions

39
README-pt_br.md Normal file
View File

@ -0,0 +1,39 @@
HardTorch v0.5.6
================
[![Baixar](https://img.shields.io/github/tag/BrunoMine/hardtorch.svg?style=flat-square&label=release)](https://github.com/BrunoMine/hardtorch/archive/master.zip)
[![Projeto](https://img.shields.io/badge/Git-Projeto-green.svg)](https://github.com/BrunoMine/hardtorch)
[![API](https://img.shields.io/badge/API-Projeto-green.svg)](https://github.com/BrunoMine/hardtorch/blob/master/API.txt)
[![!Bower](https://img.shields.io/badge/Bower-Projeto-green.svg)](https://minetest-bower.herokuapp.com/mods/hardtorch)
[![Licença](https://img.shields.io/badge/Licença-LGPL_v3.0-blue.svg)](https://github.com/BrunoMine/hardtorch/blob/master/LICENSE.txt)
Este mod vai tornar as tochas muito mais realistas.
## Requisitos
* Minetest 0.4.16 (ou superior)
* Mod default
* Mod fire
## Configuraçes
Veja as configuraçes no menu de configurações avançadas da interface grafica de Minetest ou em [minetest.conf.example](https://github.com/BrunoMine/hardtorch/blob/master/minetest.conf.example).
## Licença
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)
----------------------------------------------
Todos que não estão listados aqui:
BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0)
hardtorch_turnoff_torch.1.ogg
hardtorch_turnoff_torch.2.ogg
hardtorch_turnoff_torch.3.ogg
Jojikiba (CC BY-SA 3.0)
hardtorch_turnon_torch.ogg (editado por Lunovox)

View File

@ -1,42 +1,39 @@
HardTorch v0.5.6
================
[![Baixar](https://img.shields.io/github/tag/BrunoMine/hardtorch.svg?style=flat-square&label=release)](https://github.com/BrunoMine/hardtorch/archive/master.zip)
[![Projeto](https://img.shields.io/badge/Git-Projeto-green.svg)](https://github.com/BrunoMine/hardtorch)
[![Download](https://img.shields.io/github/tag/BrunoMine/hardtorch.svg?style=flat-square&label=release)](https://github.com/BrunoMine/hardtorch/archive/master.zip)
[![Project](https://img.shields.io/badge/Git-Projeto-green.svg)](https://github.com/BrunoMine/hardtorch)
[![API](https://img.shields.io/badge/API-Projeto-green.svg)](https://github.com/BrunoMine/hardtorch/blob/master/API.txt)
[![!Bower](https://img.shields.io/badge/Bower-Projeto-green.svg)](https://minetest-bower.herokuapp.com/mods/hardtorch)
[![Licença](https://img.shields.io/badge/Licença-LGPL_v3.0-blue.svg)](https://github.com/BrunoMine/hardtorch/blob/master/LICENSE.txt)
[![License](https://img.shields.io/badge/Licença-LGPL_v3.0-blue.svg)](https://github.com/BrunoMine/hardtorch/blob/master/LICENSE.txt)
Este mod vai tornar as tochas muito mais realistas.
_This mod will make torches much more realistic._
This mod will make torches much more realistic.
## Requisitos _(Requirements)_
* Minetest 0.4.16 (ou superior|_or later_)
* Mod default
* Mod fire
## Requirements
* Minetest 0.4.16 (or later)
* default mod
* fire mod
## Configuraçes _(Settings)_
Veja as configuraçes no menu de configurações avançadas da interface grafica de Minetest ou em [minetest.conf.example](https://github.com/BrunoMine/hardtorch/blob/master/minetest.conf.example).
_See the settings in the advanced settings menu of the Minetest GUI or in [minetest.conf.example](https://github.com/BrunoMine/hardtorch/blob/master/minetest.conf.example)._
## Settings
See the settings in the advanced settings menu of the Minetest GUI or in [minetest.conf.example](https://github.com/BrunoMine/hardtorch/blob/master/minetest.conf.example).
## Licença _(License)_
Veja LICENSE.txt para informações detalhadas da licença LGPL 3.0
_See LICENSE.txt for detailed info about LGPL 3.0 license_
## License
See LICENSE.txt for detailed info about LGPL 3.0 license
Autores do código fonte
Source code authors
-----------------------
Originalmente por BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (LGPL 3.0)
Originally by BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (LGPL 3.0)
Autores de mídias (texturas, modelos and sons)
Media authors (textures, models and sounds)
----------------------------------------------
Todos que não estão listados aqui:
All not listed here:
BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0)
hardtorch_apagando_tocha.1.ogg
hardtorch_apagando_tocha.2.ogg
hardtorch_apagando_tocha.3.ogg
hardtorch_turnoff_torch.1.ogg
hardtorch_turnoff_torch.2.ogg
hardtorch_turnoff_torch.3.ogg
Jojikiba (CC BY-SA 3.0)
hardtorch_acendendo_tocha.ogg (editado por Lunovox)
hardtorch_turnon_torch.ogg (remixed by Lunovox)

22
api.lua
View File

@ -1,36 +1,40 @@
--[[
Mod HardTorch para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Mod HardTorch for 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/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>5.
API
]]
-- Global Table
-- Tabela Global
hardtorch.registered_torchs = {}
-- Register torch
-- Registrar tocha
hardtorch.register_torch = function(name, def)
hardtorch.registered_torchs[name] = def
-- Consolidate data
-- Consolidar dados
hardtorch.registered_torchs[name].sounds = def.sounds or {}
-- Cria as ferramentas
-- Register tools (off and on)
-- Registrar ferramentas (apagada e acesa)
hardtorch.register_tool(name, def)
-- Register node
-- Registrar node
hardtorch.register_node(name, def)
-- Certifica que jogador que acabou de entrar esteja com tocha acessa, caso contrario apaga ela
-- Turn off the torch on joining the server
-- Desligue a tocha ao ingressar no servidor
minetest.register_on_joinplayer(function(player)
if hardtorch.find_item(player, name.."_on") == true then
hardtorch.apagar_tocha(player, name)
hardtorch.turnoff_torch(player, name)
end
end)
end

View File

@ -1,6 +1,6 @@
{
"name": "hardtorch",
"description": "Tochas realistas para Minetest",
"description": "Realistic torchs from Minetest",
"keywords": [
"torch",
"tochas",

View File

@ -1,18 +1,17 @@
--[[
Mod HardTorch para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Mod HardTorch for 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/>.
Metodos comuns
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>5.
Common Methods
]]
-- Play turn on torch sound
-- Tocar som de acender tocha
hardtorch.som_acender = function(pos, torchname)
hardtorch.turnon_sound = function(pos, torchname)
if hardtorch.registered_torchs[torchname].sounds.turn_on then
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.turn_on.name, {
pos = pos,
@ -23,8 +22,9 @@ hardtorch.som_acender = function(pos, torchname)
end
-- Play turn off torch sound
-- Tocar som de apagar tocha
hardtorch.som_apagar = function(pos, torchname)
hardtorch.turnoff_sound = function(pos, torchname)
if hardtorch.registered_torchs[torchname].sounds.turn_off then
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.turn_off.name, {
pos = pos,
@ -35,8 +35,9 @@ hardtorch.som_apagar = function(pos, torchname)
end
-- Play turn off torch by water sound
-- Tocar som de apagar tocha pela agua
hardtorch.som_apagar_por_agua = function(pos, torchname)
hardtorch.turnoff_by_water_sound = function(pos, torchname)
if hardtorch.registered_torchs[torchname].sounds.water_turn_off then
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.water_turn_off.name, {
pos = pos,
@ -47,12 +48,14 @@ hardtorch.som_apagar_por_agua = function(pos, torchname)
end
-- Calculate remaining time of a node
-- Calcular tempo restante de um node
hardtorch.get_node_timeout = function(pos)
local meta = minetest.get_meta(pos)
local torchname = hardtorch.registered_nodes[minetest.get_node(pos).name]
local fuel = meta:get_string("hardtorch_fuel")
-- Verifica combustivel
-- Check fuel
if fuel == "" then fuel = hardtorch.registered_torchs[torchname].fuel[1] end
local wear = meta:get_int("hardtorch_wear")
local fulltime = hardtorch.registered_fuels[fuel].time
@ -60,12 +63,15 @@ hardtorch.get_node_timeout = function(pos)
return fulltime-math.floor(time)
end
-- Calculate wear on a node
-- Calcular desgaste de um node
hardtorch.get_node_wear = function(pos)
local meta = minetest.get_meta(pos)
local fuel = meta:get_string("hardtorch_fuel")
local torchname = hardtorch.registered_nodes[minetest.get_node(pos).name]
-- Verifica combustivel
-- Check fuel
if fuel == "" then fuel = hardtorch.registered_torchs[torchname].fuel[1] end
local fulltime = hardtorch.registered_fuels[fuel].time
local timer = minetest.get_node_timer(pos)
@ -75,8 +81,8 @@ hardtorch.get_node_wear = function(pos)
end
-- Atualizar um itemstack no inventario do jogador
-- (metodo padrão set_stack() não consegue atualizar com stack vazio)
-- Update itemstack (default method 'set_stack' cannot update with an empty stack)
-- Atualiza itemstack (metodo padrão 'set_stack' não consegue atualizar com stack vazio)
hardtorch.update_inv = function(player, list, i, stack)
local inv = player:get_inventory()
local itemlist = inv:get_list(list)
@ -85,7 +91,8 @@ hardtorch.update_inv = function(player, list, i, stack)
end
-- Verificar impedimento no local proximo da tocha
-- Check nodes near torch
-- Verificar blocos perto da tocha
hardtorch.check_torch_area = function(pos)
for _,p in ipairs({
{x=pos.x+1, y=pos.y, z=pos.z},
@ -103,13 +110,16 @@ hardtorch.check_torch_area = function(pos)
end
-- Encontrar tocha acessa no inventario
-- Find and get item on inventory
-- Busca e pega item no inventario
hardtorch.find_and_get_item = function(player, itemname)
local inv = player:get_inventory()
-- Verifica cada um dos itens
-- Check each list name
for list_name,list in pairs(inv:get_lists()) do
-- Check each item
for i,item in ipairs(list) do
-- Troca pela tocha apagada
if item:get_name() == itemname then
return list_name, i, item
end
@ -118,10 +128,12 @@ hardtorch.find_and_get_item = function(player, itemname)
end
-- Encontrar tocha acessa no inventario
-- Find item on inventory
-- Busca item no inventario
hardtorch.find_item = function(player, itemname)
local inv = player:get_inventory()
-- Verifica em todas listas de inventario
-- Check each list name
for listname,list in pairs(inv:get_lists()) do
if inv:contains_item(listname, itemname) then
return true
@ -131,7 +143,8 @@ hardtorch.find_item = function(player, itemname)
end
-- Pegar combustivel no inventario de um jogador
-- Get torch fuel from inventory
-- Pegar combustivel de tocha no inventario
hardtorch.get_fuel_stack = function(player, torchname)
for _,fuelname in ipairs(hardtorch.registered_torchs[torchname].fuel) do
if hardtorch.find_item(player, fuelname) then
@ -141,13 +154,14 @@ hardtorch.get_fuel_stack = function(player, torchname)
end
-- HUD element default light
-- Elemento HUD luz padrao
hardtorch.hud_element = {
hud_elem_type = "image",
position = {x=0.1, y=1.1},
name = "hardtorch_luz",
name = "hardtorch_light",
scale = {x=4, y=4},
text = "hardtorch_luz.png",
text = "hardtorch_light.png",
number = 2,
item = 3,
direction = 0,
@ -157,22 +171,25 @@ hardtorch.hud_element = {
}
-- Adicionar luz do hud
hardtorch.adicionar_luz_hud = function(player, torchname)
hardtorch.em_loop[player:get_player_name()].hud_id = player:hud_add(hardtorch.hud_element)
-- Add light on HUD
-- Adicionar luz no HUD
hardtorch.add_light_hud = function(player, torchname)
hardtorch.in_loop[player:get_player_name()].hud_id = player:hud_add(hardtorch.hud_element)
end
-- Remover luz do hud
hardtorch.remover_luz_hud = function(player)
-- Remove light from HUD
-- Remover luz do HUD
hardtorch.remove_light_hud = function(player)
local name = player:get_player_name()
if hardtorch.em_loop[name] and hardtorch.em_loop[name].hud_id then
player:hud_remove(hardtorch.em_loop[name].hud_id)
if hardtorch.in_loop[name] and hardtorch.in_loop[name].hud_id then
player:hud_remove(hardtorch.in_loop[name].hud_id)
end
end
-- Verifica se um numero representa luz e corrige se precisar
-- Check and correct light power
-- Verifica e corrige potencia de luz
hardtorch.check_light_number = function(n)
if not n then
return 1

View File

@ -1 +1 @@
Tochas realistas (Realistic torchs)
Realistic torchs

View File

@ -1,6 +0,0 @@
Paul Rodenburg (CC BY-SA 3.0)
fosforo.ogg (editado por Lunovox)
Jojikiba (CC BY-SA 3.0)
tocha acesa.ogg (editado por Lunovox)

6
extras/authorships.txt Normal file
View File

@ -0,0 +1,6 @@
Paul Rodenburg (CC BY-SA 3.0)
phosphor.ogg (remixed by Lunovox)
Jojikiba (CC BY-SA 3.0)
lit_torch.ogg (remixed by Lunovox)

View File

@ -1,18 +1,18 @@
--[[
Mod HardTorch para Minetest
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
Mod HardTorch for 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/>.
Combustiveis
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>5.
Fuel
]]
-- Global Table
-- Tabela Global
hardtorch.registered_fuels = {}
-- Register Fuel
-- Registrar Combustivel
hardtorch.register_fuel = function(name, def)
@ -23,16 +23,18 @@ hardtorch.register_fuel = function(name, def)
registro.time = def.turns * hardtorch.night_time
registro.loop_wear = (65535/registro.time)*2
-- Override on_place to avoid tool fuel repairs
-- Sobreescreve on_place para evitar reparos no combustivel em ferramentas
if minetest.registered_tools[name] then
hardtorch.registered_fuels[name].old_on_place = minetest.registered_tools[name].on_place
hardtorch.registered_fuels[name].on_place = function(itemstack, placer, pointed_thing)
-- Check for avoidable nodes
-- Verifica nodes evitaveis
if pointed_thing.under and hardtorch.evitar_tool_on_place[1] then
if pointed_thing.under and hardtorch.not_place_torch_on[1] then
local nn = minetest.get_node(pointed_thing.under).name
for _,n in ipairs(hardtorch.evitar_tool_on_place) do
for _,n in ipairs(hardtorch.not_place_torch_on) do
if n == nn then
return
end

View File

@ -1,34 +1,44 @@
--[[
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/>.
Inicializador de scripts
Mod HardTorch for Minetest
Copyright (C) 2019 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/>5.
]]
-- Global Table
-- Tabela Global
hardtorch = {}
-- Tabela de jogadores em loop de tocha acessa
hardtorch.em_loop = {}
-- Players in loop to torchs on
-- Jogadores em loop de tocha acesa
hardtorch.in_loop = {}
-- Require fire source to light torch
-- Requerer fonte de fogo para acender tocha
hardtorch.torch_lighter = (minetest.settings:get("hardtorch_torch_lighter") == "true") or false
-- Nodes que funcionam como fontes de fogo para acender tochas
hardtorch.fontes_de_fogo = {}
-- Fire sources (nodes that act as fire sources to light torches)
-- Fontes de fogo (nodes que funcionam como fontes de fogo para acender tochas)
hardtorch.fire_sources = {}
-- Nodes to avoid when placing torches
-- Nodes para evitar ao colocar tochas
hardtorch.evitar_tool_on_place = {}
-- Mod Anvil
hardtorch.not_place_torch_on = {}
-- Anvil Mod
if minetest.get_modpath("anvil") then
table.insert(hardtorch.evitar_tool_on_place, "anvil:anvil")
table.insert(hardtorch.not_place_torch_on, "anvil:anvil")
end
-- Fixed time for a night
-- Tempo fixo de duração de uma noite
hardtorch.night_time = tonumber(minetest.settings:get("hardtorch_fixed_night_time") or 0)
if hardtorch.night_time == 0 then
@ -39,48 +49,58 @@ if hardtorch.night_time == 0 then
hardtorch.night_time = (12*60*60)/time_speed
end
-- Notify load
-- Notificador de Inicializador
local notificar = function(msg)
local notify = function(msg)
if minetest.settings:get("log_mods") then
minetest.debug("[HardTorch]"..msg)
minetest.debug("[HardTorch] "..msg)
end
end
-- Modpath
local modpath = minetest.get_modpath("hardtorch")
-- Carregar scripts
notificar("Carregando...")
-- Metodos gerais
dofile(modpath.."/comum.lua")
dofile(modpath.."/luz.lua")
notify("Loading...")
-- API
dofile(modpath.."/common.lua")
dofile(modpath.."/light.lua")
dofile(modpath.."/tool.lua")
dofile(modpath.."/node.lua")
dofile(modpath.."/lighter.lua")
dofile(modpath.."/fuel.lua")
dofile(modpath.."/api.lua")
-- Content
dofile(modpath.."/oil.lua")
dofile(modpath.."/torchs/torch.lua")
dofile(modpath.."/torchs/lamp.lua")
dofile(modpath.."/torchs/xdecor_candle.lua")
notificar("[OK]!")
notify("OK!")
-- Preset
-- Pré ajustes
-- Lighter Flint and Steel
-- Acendedor de pederneira
hardtorch.register_lighter("fire:flint_and_steel", {
wear_by_use = 1000
})
-- Fire source nodes
-- Nodes fonte de fogo
hardtorch.fontes_de_fogo["default:furnace_active"] = true
hardtorch.fontes_de_fogo["default:lava_flowing"] = true
hardtorch.fontes_de_fogo["default:lava_source"] = true
hardtorch.fontes_de_fogo["fire:basic_flame"] = true
hardtorch.fontes_de_fogo["fire:permanent_flame"] = true
hardtorch.fire_sources["default:furnace_active"] = true
hardtorch.fire_sources["default:lava_flowing"] = true
hardtorch.fire_sources["default:lava_source"] = true
hardtorch.fire_sources["fire:basic_flame"] = true
hardtorch.fire_sources["fire:permanent_flame"] = true
-- Campfire Mod
if minetest.get_modpath("campfire") then
hardtorch.fontes_de_fogo["campfire:campfire_active"] = true
hardtorch.fire_sources["campfire:campfire_active"] = true
end

144
light.lua Normal file
View File

@ -0,0 +1,144 @@
--[[
Mod HardTorch for Minetest
Copyright (C) 2019 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/>5.
Light
]]
-- Get light position
-- Pegar coordenada de luz
hardtorch.get_lpos = function(player)
local p = minetest.deserialize(minetest.serialize(player:getpos()))
p.y = p.y+1
return minetest.deserialize(minetest.serialize(p))
end
-- Check light
-- Verificar luz
local check_light_node = function(pos)
local meta = minetest.get_meta(pos)
if meta:get_string("nome") == "" then
minetest.add_node(pos, {name="hardtorch:light_0"})
minetest.remove_node(pos)
end
end
-- Light nodes
-- Nodes de luz
local light_nodes = {}
for _,light in ipairs({"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"}) do
table.insert(light_nodes, "hardtorch:light_"..light)
minetest.register_node("hardtorch:light_"..light, {
drawtype = "airlike",
groups = {not_in_creative_inventory = 1},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
light_source = tonumber(light),
pointable = false,
buildable_to = true,
drop = {},
on_place = function(itemstack, placer, pointed_thing)
itemstack:clear()
minetest.after(1, check_light_node, pointed_thing.above)
return itemstack
end,
on_timer = function(pos, elapsed)
local meta = minetest.get_meta(pos)
-- Check if player still has light
-- Verifica se jogador ainda tem luz no local
if hardtorch.in_loop[meta:get_string("nome")]
and vector.equals(hardtorch.in_loop[meta:get_string("nome")].lpos, pos) == true
then
-- Continue to the next timer
-- Repete loop do timer
return true
end
-- Remove node
minetest.remove_node(pos)
end,
on_drop = function(itemstack, dropper, pos)
itemstack:clear()
return itemstack
end,
})
end
-- Light loop for players (makes light follow player)
-- Loop de luz para jogadores (faz a luz acompanhar jogador)
hardtorch.light_loop = function(name, torchname)
if not hardtorch.in_loop[name] then return end
local player = minetest.get_player_by_name(name)
if not player then return end
-- Checks if current pos has light
-- Verifica se pos atual tem luz
local current_light_pos = hardtorch.get_lpos(player)
local last_light_pos = hardtorch.in_loop[name].lpos
if not string.match(minetest.get_node(current_light_pos).name, "hardtorch:light_") then
-- Remove light from last position
-- Remove luz do local antigo
if string.match(minetest.get_node(last_light_pos).name, "hardtorch:light_") then
minetest.remove_node(last_light_pos)
end
-- Set light on new position
-- Coloca luz no novo local
if minetest.get_node(current_light_pos).name == "air" then
minetest.add_node(current_light_pos, {name="hardtorch:light_"..hardtorch.registered_torchs[torchname].light_source})
end
local meta = minetest.get_meta(current_light_pos)
meta:set_string("nome", name)
minetest.get_node_timer(current_light_pos):start(1)
-- Save new light position for this player
-- Salva novo local de luz desse jogar
hardtorch.in_loop[name].lpos = vector.round(current_light_pos)
-- Convert old light nodes
minetest.register_alias(
"hardtorch:luz_"..hardtorch.registered_torchs[torchname].light_source,
"hardtorch:light_"..hardtorch.registered_torchs[torchname].light_source
)
end
minetest.after(0.45, hardtorch.light_loop, name, torchname)
end
-- Force light extinction
-- Força extinção de luz
hardtorch.apagar_node_luz = function(name)
if hardtorch.in_loop[name]
and hardtorch.in_loop[name].lpos
and string.match(minetest.get_node(hardtorch.in_loop[name].lpos).name, "hardtorch:light_")
then
minetest.remove_node(hardtorch.in_loop[name].lpos)
end
end
-- Remove residual light
-- Remove luz residual indevida
minetest.register_lbm({
label = "Remove residual light",
name = "hardtorch:remove_light",
nodenames = light_nodes,
run_at_every_load = true,
action = function(pos, node)
minetest.remove_node(pos)
end,
})

View File

@ -1,18 +1,18 @@
--[[
Mod HardTorch para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Mod HardTorch for 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/>.
Acendedores
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>5.
Lighter
]]
-- Global Table
-- Tabela global
hardtorch.registered_lighters = {}
-- Register lighter
-- Registrar Acendedor
hardtorch.register_lighter = function(name, def)
hardtorch.registered_lighters[name] = def

122
luz.lua
View File

@ -1,122 +0,0 @@
--[[
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/>.
Iluminação
]]
-- Pegar coordenada de luz
hardtorch.get_lpos = function(player)
local p = minetest.deserialize(minetest.serialize(player:getpos()))
p.y = p.y+1
return minetest.deserialize(minetest.serialize(p))
end
-- Verificar luz
local check_node_luz = function(pos)
local meta = minetest.get_meta(pos)
if meta:get_string("nome") == "" then
minetest.add_node(pos, {name="hardtorch:luz_0"})
minetest.remove_node(pos)
end
end
-- Nodes de luz
local nodes_luz_tb = {}
for _,light in ipairs({"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"}) do
table.insert(nodes_luz_tb, "hardtorch:luz_"..light)
minetest.register_node("hardtorch:luz_"..light, {
drawtype = "airlike",
groups = {not_in_creative_inventory = 1},
walkable = false,
paramtype = "light",
sunlight_propagates = true,
light_source = tonumber(light),
pointable = false,
buildable_to = true,
drop = {},
on_place = function(itemstack, placer, pointed_thing)
itemstack:clear()
minetest.after(1, check_node_luz, pointed_thing.above)
return itemstack
end,
on_timer = function(pos, elapsed)
local meta = minetest.get_meta(pos)
-- Verifica se jogador ainda tem luz no local
if hardtorch.em_loop[meta:get_string("nome")]
and vector.equals(hardtorch.em_loop[meta:get_string("nome")].lpos, pos) == true
then
return true -- Repete loop do timer
end
-- remove bloco
minetest.remove_node(pos)
end,
on_drop = function(itemstack, dropper, pos)
itemstack:clear()
return itemstack
end,
})
end
-- Loop de luz para jogadores (faz a luz acompanhar jogador)
hardtorch.loop_luz = function(name, torchname)
if not hardtorch.em_loop[name] then return end
local player = minetest.get_player_by_name(name)
if not player then return end
-- Verifica se pos atual tem luz
local lpa = hardtorch.get_lpos(player) -- coordenada onde deve ter luz atualmente
local lpos = hardtorch.em_loop[name].lpos
if not string.match(minetest.get_node(lpa).name, "hardtorch:luz_") then
-- Remove luz do local antigo
if string.match(minetest.get_node(lpos).name, "hardtorch:luz_") then
minetest.remove_node(lpos)
end
-- Coloca no novo local
if minetest.get_node(lpa).name == "air" then
minetest.add_node(lpa, {name="hardtorch:luz_"..hardtorch.registered_torchs[torchname].light_source})
end
local meta = minetest.get_meta(lpa)
meta:set_string("nome", name)
minetest.get_node_timer(lpa):start(1)
-- Salva novo local de luz atual do jogador
hardtorch.em_loop[name].lpos = vector.round(lpa)
end
minetest.after(0.45, hardtorch.loop_luz, name, torchname)
end
-- Forças extinção de luz
hardtorch.apagar_node_luz = function(name)
if hardtorch.em_loop[name]
and hardtorch.em_loop[name].lpos
and string.match(minetest.get_node(hardtorch.em_loop[name].lpos).name, "hardtorch:luz_")
then
minetest.remove_node(hardtorch.em_loop[name].lpos)
end
end
-- Remove luz residual indevida
minetest.register_lbm({
label = "Remover luz residual",
name = "hardtorch:remove_light",
nodenames = nodes_luz_tb,
run_at_every_load = true,
action = function(pos, node)
minetest.remove_node(pos)
end,
})

115
node.lua
View File

@ -1,70 +1,76 @@
--[[
Mod HardTorch para Minetest
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
Mod HardTorch for 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/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>5.
Nodes
]]
-- Registered nodes
-- Nodes registrados
hardtorch.registered_nodes = {}
-- Register torch node
-- Registrar Node de tocha
hardtorch.register_node = function(torchname, def)
for nt,nn in pairs(def.nodes) do
hardtorch.registered_nodes[nn] = torchname
if def.nodes.fire_source ~= false then
hardtorch.fontes_de_fogo[nn] = true
hardtorch.fire_sources[nn] = true
end
end
-- Recuperar o desgaste apos coletado
-- Take torch and fuel with wear
-- Pega tocha e combustivel com desgaste
local on_dig = function(pos, node, digger)
if not hardtorch.registered_nodes[node.name] then return end
local meta = minetest.get_meta(pos)
local inv = digger:get_inventory()
-- Calcula desgaste
-- Calculate wear
local wear = hardtorch.get_node_wear(pos)
local itemstack = {name=torchname, count=1}
-- Caso o combustivel seja o proprio item, repassa desgaste
-- If torch is the fuel
-- Se a tocha é o próprio cosbustivel
local torch_is_fuel = false
if torchname.."_on" == meta:get_string("hardtorch_fuel") then
itemstack.wear = wear
torch_is_fuel = true
end
-- Torna acessa caso ainda nao tenha nenhuma (sem loop)
if not hardtorch.em_loop[digger:get_player_name()] then
-- Keep torch lit if possible
-- Deixa tocha acesa se possivel
if not hardtorch.in_loop[digger:get_player_name()] then
itemstack.name = torchname.."_on"
end
-- Checks if torch fits in inventory
-- Verifica se tocha cabe no inventario
if inv:room_for_item("main", itemstack) then
-- Coloca no inventario
inv:add_item("main", itemstack)
-- Lights with loop if added previously lit
-- Acende com loop caso adicinou acesa anteriormente
if not hardtorch.em_loop[digger:get_player_name()] then
if not hardtorch.in_loop[digger:get_player_name()] then
local list, i, itemstack = hardtorch.find_and_get_item(digger, torchname.."_on")
itemstack:set_name(torchname)
itemstack = hardtorch.acender_tocha(itemstack, digger)
itemstack = hardtorch.turnon_torch(itemstack, digger)
inv:set_stack(list, i, itemstack)
end
else
-- Dropa no local
-- Drop torch
minetest.add_item(pos, itemstack)
end
-- Checks if fuel fits in inventory
-- Verifica se combustivel cabe no inventario
if torchname.."_on" ~= meta:get_string("hardtorch_fuel") then
if torch_is_fuel == false then
local fuelstack = {name=meta:get_string("hardtorch_fuel"), count=1, wear=wear}
if inv:room_for_item("main", fuelstack) then
@ -72,72 +78,89 @@ hardtorch.register_node = function(torchname, def)
-- Coloca no inventario
inv:add_item("main", fuelstack)
else
-- Dropa no local
-- Drop fuel
minetest.add_item(pos, fuelstack)
end
end
minetest.remove_node(pos)
end
-- Adiciona uso para node de tochas ser substituindo por ferramenta de tocha (que será acessa)
-- Replaces craftitem/node in a tool (to be lit)
-- Troca craftitem/nó em ferramenta (para ser acesa)
local on_use = function(itemstack, player, pointed_thing)
if not hardtorch.registered_nodes[itemstack:get_name()] then return end
local sobra = itemstack:get_count() - 1
local leftover = itemstack:get_count() - 1
local inv = player:get_inventory()
-- Localize the item on inventory
-- Localiza o item no iventario
local list, i = player:get_wield_list(), player:get_wield_index()
local itemstack2 = inv:get_stack(list, i)
if itemstack:to_string() ~= itemstack2:to_string() then
return
end
-- Troca o item pela ferramenta
-- Replace item
itemstack:replace({name=torchname, count=1, wear=0, metadata=""})
inv:set_stack(list, i, itemstack)
-- If has left over, try put on inventory or drop (with audible and textual warning)
-- Caso tenha sobra tenta colocar no inventario, ou joga no chão (com aviso sonoro e textual)
if sobra > 0 then
if inv:room_for_item("main", def.nodes.node.." "..sobra) then
-- Coloca no inventario
inv:add_item("main", def.nodes.node.." "..sobra)
if leftover > 0 then
-- Put in inventory
if inv:room_for_item("main", def.nodes.node.." "..leftover) then
inv:add_item("main", def.nodes.node.." "..leftover)
-- Drop
else
-- Coloca a tocha no inventario para poder dropa-la
inv:set_stack(list, i, def.nodes.node.." "..sobra)
-- Set torchs in inveotory to drop
-- Coloca a tocha no inventario para dropar
inv:set_stack(list, i, def.nodes.node.." "..leftover)
minetest.item_drop(inv:get_stack(list, i), player, player:getpos())
-- Recoloca tocha
-- Restore to the torch tool
-- Restaura para a ferramenta tocha
inv:set_stack(list, i, itemstack)
end
end
itemstack:set_name(torchname) -- restaura nome da tocha
-- Restore torch name
-- Restaura nome da tocha
itemstack:set_name(torchname)
return itemstack
end
-- Atualiza as tocha apos colocar
-- Update the torch after place it
-- Atualiza a tocha apos coloca-la
local after_place_node = function(pos, placer, itemstack, pointed_thing)
if not hardtorch.registered_nodes[minetest.get_node(pos).name] then return end
-- Certifica de que iniciou contagem
-- Starts wear time count
-- Inicia contagem de tempo de desgaste
local timer = minetest.get_node_timer(pos)
if timer:is_started() ~= true then
-- Set initial wear if necessary
-- Define desgaste inicial caso necessario
local meta = minetest.get_meta(pos)
if meta:get_string("hardtorch_fuel") == "" then
meta:set_string("hardtorch_fuel", def.fuel[1])
meta:set_int("hardtorch_wear", 0)
end
-- Starts counting to end fire according to set wear
-- Inicia contagem para acabar fogo de acordo com desgaste definido
timer:start(hardtorch.get_node_timeout(pos))
end
end
-- Remove torch when fire end
-- Remove tocha quando fogo acabar
local on_timer = function(pos, elapsed)
if not hardtorch.registered_nodes[minetest.get_node(pos).name] then return end
@ -166,6 +189,7 @@ hardtorch.register_node = function(torchname, def)
on_timer=on_timer,
}
-- Prevent normal placement in special cases
-- Impedir colocação normal em casos especiais
if hardtorch.torch_lighter then
node_torch_def.on_place = function(itemstack, placer, pointed_thing)
@ -173,15 +197,16 @@ hardtorch.register_node = function(torchname, def)
end
end
-- Atualiza tochas com novas funcões de chamadas
-- Upgrades torches with new calling features
-- Atualiza tochas com novas funções de chamadas
minetest.override_item(def.nodes.node, node_torch_def)
minetest.override_item(def.nodes.node_ceiling or def.nodes.node, node_torch_def)
minetest.override_item(def.nodes.node_wall or def.nodes.node, node_torch_def)
-- Turn off torches in contact with water
-- Apagar tochas em contato com agua
minetest.register_abm({
label = "Esfriamento de tochas molhadas",
label = "Turn off wet torch",
nodenames = {def.nodes.node, def.nodes.node_ceiling, def.nodes.node_wall},
neighbors = {"group:water"},
interval = 1,
@ -190,7 +215,7 @@ hardtorch.register_node = function(torchname, def)
action = function(pos, node)
if hardtorch.check_torch_area(pos) == false then
local wear = hardtorch.get_node_wear(pos)
hardtorch.som_apagar_por_agua(pos, torchname)
hardtorch.turnoff_by_water_sound(pos, torchname)
minetest.remove_node(pos)
minetest.add_item(pos, def.drop_on_water or {name=torchname, wear=wear})
end

27
oil.lua
View File

@ -1,38 +1,37 @@
--[[
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/>.
Registro de Oleo
Mod HardTorch for Minetest
Copyright (C) 2019 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/>5.
Oil
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Noites de durabilidade da tocha da lamparina
-- Durability of oil (in nights)
-- Durabilidade do oleo (em noites)
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
-- Oil
-- Oleo
minetest.register_tool("hardtorch:oil", {
description = S("Oil"),
inventory_image = "hardtorch_oil.png",
})
-- Register fuel
-- Registrar combustivel
hardtorch.register_fuel("hardtorch:oil", {
turns = oil_nights,
})
-- Oil recipes
-- Receitas para oleo
minetest.register_craft({
output = 'hardtorch:oil',

View File

@ -1,31 +1,33 @@
# Configurações aplicaveis para o menu gráfico
# Settings Applicable by GUI
# Numero de noites que uma Tocha perdura acesa.
# Number of nights a Torch remains lit.
hardtorch_torch_nights (Durabilidade - Tocha) float 0.1 0
# Numero de noites que uma Tocha perdura acesa.
hardtorch_torch_nights (Durability - Torch) float 0.1 0
# Numero de noites que uma porção de Oleo perdura acesa.
# Number of nights a portion of Oil remains lit.
hardtorch_oil_nights (Durabilidade - Oleo/Oil) float 1.2 0
# Numero de noites que uma porção de Oleo perdura acesa.
hardtorch_oil_nights (Durability - Oil) float 1.2 0
# Luminosidade da Tocha Acesa (limite: 14)
# Light source of Torch Lit (limit: 14)
hardtorch_torch_light_source (Luminosidade - Tocha) int 11 0
# Luminosidade da Tocha Acesa (limite: 14)
hardtorch_torch_light_source (Light - Torch) int 11 0
# Luminosidade da Lamparina Acesa (limite: 14)
# Light source of Oil Lamp Lit (limit: 14)
hardtorch_lamp_light_source (Luminosidade - Lamparina/Oil Lamp) int 13 0
# Luminosidade da Lamparina Acesa (limite: 14)
hardtorch_lamp_light_source (Light - Oil Lamp) int 13 0
# É necessario acendedor ou fonte de fogo para acender uma tocha.
# Lighter or fire source is needed to light a torch.
hardtorch_torch_lighter (Acendedor/lighter) bool false
# É necessario acendedor ou fonte de fogo para acender uma tocha.
hardtorch_torch_lighter (Lighter is necessary) bool false
# Tempo fixo (em segundos) que dura uma noite.
# Isso vai ignorar a verdadeira duração da noite no jogo.
# Definir 0 para desabilitar.
# Fixed time (in seconds) that lasts one night.
# This will ignore the true duration of the night in the game.
# Set 0 to disable.
hardtorch_fixed_night_time (Tempo fixo da noite/Fixed night time) int 0
#
# Tempo fixo (em segundos) que dura uma noite.
# Isso vai ignorar a verdadeira duração da noite no jogo.
# Definir 0 para desabilitar.
hardtorch_fixed_night_time (Fixed night time) int 0

View File

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 449 B

View File

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 438 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 456 B

View File

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

View File

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 165 B

View File

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

View File

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 205 B

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 75 B

After

Width:  |  Height:  |  Size: 75 B

285
tool.lua
View File

@ -1,99 +1,119 @@
--[[
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/>.
Ferramentas
Mod HardTorch for Minetest
Copyright (C) 2019 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/>5.
Tool
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Turn on torch
-- Acender tocha
hardtorch.acender_tocha = function(itemstack, player)
hardtorch.turnon_torch = 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
hardtorch.em_loop[name] = {
-- Check if it is already lit (avoid double loop)
-- Verifica se ja esta acesa (evitar loop duplo)
if not hardtorch.in_loop[name] then
hardtorch.in_loop[name] = {
lpos = hardtorch.get_lpos(player),
torchname = torchname,
}
-- Adiciona luz no hud
hardtorch.adicionar_luz_hud(player, torchname)
-- Add HUD element
hardtorch.add_light_hud(player, torchname)
-- Start torch loop (delay to allow time to update item in inventory)
-- Inicia loop de tocha (atraso para dar tempo de atualizar item no inventario)
minetest.after(0.3, hardtorch.loop_tocha, name, torchname)
-- Inicia loop de luz
hardtorch.loop_luz(name, torchname)
-- Som
hardtorch.som_acender(player:getpos(), torchname)
minetest.after(0.3, hardtorch.torch_loop, name, torchname)
-- Start light loop
hardtorch.light_loop(name, torchname)
-- Play sound
hardtorch.turnon_sound(player:getpos(), torchname)
end
return itemstack
end
-- Apaga todas as tochas que um jogador possui
hardtorch.apagar_tocha = function(player, torchname)
-- Remover luz do hud
hardtorch.remover_luz_hud(player)
-- Turn off torchs
-- Apagar tochas
hardtorch.turnoff_torch = function(player, torchname)
local loop = hardtorch.em_loop[player:get_player_name()]
-- Remove HUD element
hardtorch.remove_light_hud(player)
local loop = hardtorch.in_loop[player:get_player_name()]
torchname = torchname or loop.torchname
-- Pega a tocha
-- Take torch
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
if list then
local inv = player:get_inventory()
-- Coloca no lugar
-- Set torch off
itemstack:set_name(torchname)
inv:set_stack(list, i, itemstack)
end
end
-- Inicia loop de verificação apos acender tocha
hardtorch.loop_tocha = function(name, torchname)
-- Verifica se ja iniciou loop
if not hardtorch.em_loop[name] then return end
-- Verifica jogador
-- Start torch loop (for mantain torch working)
-- Inicia loop da tocha (para manter tocha funcionando)
hardtorch.torch_loop = function(name, torchname)
-- Check if it is already lit (avoid double loop)
-- Verifica se ja esta acesa (evitar loop duplo)
if not hardtorch.in_loop[name] then return end
-- Check player
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 loop = hardtorch.in_loop[name]
-- Torch
-- Tocha
-- Check torch
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
if not itemstack then
-- Encerra loop
hardtorch.apagar_tocha(player, torchname)
hardtorch.em_loop[name] = nil
-- Finish loop
hardtorch.turnoff_torch(player, torchname)
hardtorch.in_loop[name] = nil
return
end
-- Verifica se tem lugar para a luz
-- Check air for torch light
-- Verifica ar para luz da tocha
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
if nn ~= "air" and not string.match(nn, "hardtorch:light_") then
-- Finish loop
hardtorch.turnoff_torch(player, torchname)
hardtorch.in_loop[name] = nil
return
end
end
-- Fuel
-- Combustivel
-- Update fuel wear
-- Atualiza combustivel em uso
local inv = player:get_inventory()
if not loop.fuel or inv:get_stack(loop.fuel.list, loop.fuel.i):get_name() ~= loop.fuel.name then
@ -104,85 +124,104 @@ hardtorch.loop_tocha = function(name, torchname)
loop.fuel = {list=listfuel, i=indexfuel, name=itemfuel:get_name()}
end
end
-- Consome o Combustivel
-- Add wear to fuel item
-- Consome o Combustivel no inventario
if loop.fuel then
local item = inv:get_stack(loop.fuel.list, loop.fuel.i)
item:add_wear(hardtorch.registered_fuels[loop.fuel.name].loop_wear)
inv:set_stack(loop.fuel.list, loop.fuel.i, item)
else
-- "Without fuel" warning
-- Aviso de "sem combustivel"
if torchname ~= def.fuel[1] then
minetest.chat_send_player(player:get_player_name(), S("Without fuel"))
end
-- Finish loop
-- Encerra loop
hardtorch.apagar_tocha(player, torchname)
hardtorch.em_loop[name] = nil
hardtorch.turnoff_torch(player, torchname)
hardtorch.in_loop[name] = nil
return
end
-- Verifica se acabou a tocha durante o loop
-- Checks if fuel runs out during loop
-- Verifica se acabou o combustivel durante o loop
if itemstack:is_empty() then
-- Finish loop
-- Encerra loop
hardtorch.apagar_tocha(player, torchname)
hardtorch.em_loop[name] = nil
hardtorch.turnoff_torch(player, torchname)
hardtorch.in_loop[name] = nil
return
end
-- Verifica se luz do hud foi criada
-- Check if HUD element has been added
-- Verifique se o elemento HUD foi adicionado
if not loop.hud_id
or not player:hud_get(loop.hud_id)
then
hardtorch.adicionar_luz_hud(player, torchname)
hardtorch.add_light_hud(player, torchname)
end
-- Prepara para proximo loop
minetest.after(2, hardtorch.loop_tocha, name, torchname)
-- Wait for next loop
-- Aguarda para proximo loop
minetest.after(2, hardtorch.torch_loop, name, torchname)
end
-- Registra as ferramentas
-- Register tool
-- Registrar ferramenta
hardtorch.register_tool = function(torchname, def)
-- Adjust the created tool
-- 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
-- Check if it is already lit (avoid double loop)
-- Verifica se ja esta acesa (evitar loop duplo)
if hardtorch.in_loop[user:get_player_name()] then
return
end
-- Verifica se tem fonte de fogo
-- Check if need fire source
-- Verifica se precisa de 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]
-- Check if turn on from fire source node
-- Verifica se acendeu em bloco de fonte de fogo
if pointed_thing.under and hardtorch.fire_sources[minetest.get_node(pointed_thing.under).name]
or pointed_thing.above and hardtorch.fire_sources[minetest.get_node(pointed_thing.above).name]
then
return hardtorch.acender_tocha(itemstack, user)
return hardtorch.turnon_torch(itemstack, user)
end
-- Check if turn on with lighter
-- Verifica se acendeu com acendedor
for tool,def in pairs(hardtorch.registered_lighters) do
if hardtorch.find_item(user, tool) then
local list, i, item = hardtorch.find_and_get_item(user, tool)
item:add_wear(def.wear_by_use)
user:get_inventory():set_stack(list, i, item)
return hardtorch.acender_tocha(itemstack, user)
return hardtorch.turnon_torch(itemstack, user)
end
end
minetest.chat_send_player(user:get_player_name(), S("Without heat source or lighter"))
return itemstack
end
return hardtorch.acender_tocha(itemstack, user)
return hardtorch.turnon_torch(itemstack, user)
end,
-- Ao colocar funciona como tocha normal apenas repassando o desgaste
-- Place torch tool like a torch node
-- Coloca ferramenta de tocha como nó de tocha
on_place = function(itemstack, placer, pointed_thing)
-- Check for avoidable nodes
-- Verifica nodes evitaveis
if pointed_thing.under and hardtorch.evitar_tool_on_place[1] then
if pointed_thing.under and hardtorch.not_place_torch_on[1] then
local nn = minetest.get_node(pointed_thing.under).name
for _,n in ipairs(hardtorch.evitar_tool_on_place) do
for _,n in ipairs(hardtorch.not_place_torch_on) do
if n == nn then
return
end
@ -194,8 +233,9 @@ hardtorch.register_tool = function(torchname, def)
if pointed_thing.type ~= "node" then
return itemstack
end
-- Verifica se esta acessando outro node
-- Check if is right clicking a node
-- Verifica se esta acessando outro nó
local under = pointed_thing.under
local node = minetest.get_node(under)
local defnode = minetest.registered_nodes[node.name]
@ -204,17 +244,20 @@ hardtorch.register_tool = function(torchname, def)
return defnode.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
-- Checks for any impediments in place
-- Verifica se tem algum impedimento no local
if hardtorch.check_torch_area(pointed_thing.above) == false then
return itemstack
end
-- Verificar se é um node
-- Check if is a node
-- Verificar se é um nó
if not minetest.registered_nodes[torchname] then
return itemstack
end
-- Set node according to side placement
-- Definir node de acordo com posicionamento
local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
@ -225,8 +268,9 @@ hardtorch.register_tool = function(torchname, def)
else
itemstack:set_name(def.nodes.node_wall or def.nodes.node)
end
-- Coloca node apagado
-- Set turned off torch
-- Coloca nó de tocha apagado
if hardtorch.registered_torchs[torchname].nodes_off then
itemstack:set_name(hardtorch.registered_torchs[torchname].nodes_off.node)
end
@ -234,7 +278,7 @@ hardtorch.register_tool = function(torchname, def)
return itemstack
end
-- Remove item do inventario
-- Remove item from inventory
itemstack:take_item()
return itemstack
@ -242,14 +286,16 @@ hardtorch.register_tool = function(torchname, def)
end,
})
-- Versao acessa
-- Lit version
-- Versao acesa
minetest.override_item(torchname.."_on", {
wield_image = "hardtorch_torch_tool_on_mao.png",
wield_image = "hardtorch_torch_tool_on_wield.png",
on_use = function(itemstack, user, pointed_thing)
-- Verifica se node acerta tem interação
-- Check if is punching another node
-- Verifica se batendo em outro nó
local under = pointed_thing.under
if under then
local node = minetest.get_node(under)
@ -264,10 +310,10 @@ hardtorch.register_tool = function(torchname, def)
if itemstack:get_name() ~= torchname.."_on" then return end
-- Remover luz
hardtorch.som_apagar(user:getpos(), torchname)
-- Remove light from player
hardtorch.turnoff_sound(user:getpos(), torchname)
hardtorch.apagar_node_luz(user:get_player_name())
hardtorch.remover_luz_hud(user)
hardtorch.remove_light_hud(user)
itemstack:set_name(torchname)
return itemstack
@ -276,23 +322,25 @@ hardtorch.register_tool = function(torchname, def)
on_drop = function(itemstack, dropper, pos)
if itemstack:get_name() ~= torchname.."_on" then return end
-- Remover luz
-- Remove light from player
hardtorch.apagar_node_luz(dropper:get_player_name())
hardtorch.remover_luz_hud(dropper)
hardtorch.remove_light_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
-- When place works like a torch with current fuel wear
-- Ao colocar funciona como tocha com desgaste atual de combustivel
on_place = function(itemstack, placer, pointed_thing)
-- Check for avoidable nodes
-- Verifica nodes evitaveis
if pointed_thing.under and hardtorch.evitar_tool_on_place[1] then
if pointed_thing.under and hardtorch.not_place_torch_on[1] then
local nn = minetest.get_node(pointed_thing.under).name
for _,n in ipairs(hardtorch.evitar_tool_on_place) do
for _,n in ipairs(hardtorch.not_place_torch_on) do
if n == nn then
return
end
@ -305,7 +353,8 @@ hardtorch.register_tool = function(torchname, def)
return itemstack
end
-- Verifica se esta acessando outro node
-- Check if is right clicking a node
-- Verifica se esta acessando outro nó
local under = pointed_thing.under
local node = minetest.get_node(under)
local defnode = minetest.registered_nodes[node.name]
@ -315,24 +364,27 @@ hardtorch.register_tool = function(torchname, def)
pointed_thing) or itemstack
end
-- Verifica se ja iniciou loop
local loop = hardtorch.em_loop[placer:get_player_name()]
-- Check if it is already lit (avoid double loop)
-- Verifica se ja esta acesa (evitar loop duplo)
local loop = hardtorch.in_loop[placer:get_player_name()]
if not loop then
return itemstack
end
-- Verifica se tem combustivel
-- Check fuel
-- Verifica 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
-- Checks for any impediments in place
-- Verifica se tem algum impedimento no local
if hardtorch.check_torch_area(pointed_thing.above) == false then
return itemstack
end
-- Set node according to side placement
-- Definir node de acordo com posicionamento
local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
@ -349,8 +401,9 @@ hardtorch.register_tool = function(torchname, def)
if not itemstack then
return
end
-- Repassa desgaste de combustivel
-- Set fuel wear to node
-- Repassa desgaste de combustivel ao nó
local fuelname, fuelwear
fuelname = loop.fuel.name
fuelwear = inv:get_stack(loop.fuel.list, loop.fuel.i):get_wear()
@ -364,12 +417,12 @@ hardtorch.register_tool = function(torchname, def)
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
-- Remove item from inventory
itemstack:take_item()
-- Remover luz
-- Remove light from player
hardtorch.apagar_node_luz(placer:get_player_name())
hardtorch.remover_luz_hud(placer)
hardtorch.remove_light_hud(placer)
return itemstack
end,
@ -377,12 +430,14 @@ hardtorch.register_tool = function(torchname, def)
end
-- Turn off wielded torch when player disconnect
-- Apaga tocha da mão quando o jogador desconecta
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
if hardtorch.em_loop[name] then
hardtorch.apagar_tocha(player, hardtorch.em_loop[name].torchname)
hardtorch.em_loop[name] = nil
if hardtorch.in_loop[name] then
hardtorch.turnoff_torch(player, hardtorch.in_loop[name].torchname)
hardtorch.in_loop[name] = nil
end
end)

View File

@ -1,29 +1,27 @@
--[[
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/>.
Registro de Lamparina
Mod HardTorch for Minetest
Copyright (C) 2019 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/>5.
Oil Lamp
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Luminosidade da lamparina
-- Oil Lamp light
-- Luminosidade da Lamparina
local lamp_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_lamp_light_source") or 13)
local tile_anim = {
name = "hardtorch_lamp_lado_active.png",
name = "hardtorch_lamp_side_active.png",
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}
-- Node-ferramenta
-- Tool nodebox
local tool_nodebox = {
type = "fixed",
fixed = {
@ -37,44 +35,43 @@ local tool_nodebox = {
{0.25, -0.375, -0.375, 0.375, 0.5, -0.25}, -- NodeBox4
{-0.375, -0.375, -0.375, -0.25, 0.5, -0.25}, -- NodeBox5
{-0.375, -0.375, 0.25, -0.25, 0.5, 0.375}, -- NodeBox6
{-0.125, 0, -0.125, 0.125, 0.5, 0.125}, -- Vela
{-0.125, 0, -0.125, 0.125, 0.5, 0.125}, -- Candle
{-0.5, -0.5+1, -0.5, 0.5, -0.375+1, 0.5}, -- NodeBox1
{-0.25, -0.375+1, -0.25, 0.25, -0.25+1, 0.25}, -- NodeBox2
}
}
-- Nodeboxes
-- Node nodebox
local node_nodebox = {
type = "fixed",
fixed = {
{-0.1875, -0.4375, 0.0625, 0.1875, -0.25, 0.1875}, -- Tanque1
{-0.1875, -0.4375, -0.1875, 0.1875, -0.25, -0.0625}, -- Tanque2
{-0.1875, -0.4375, -0.0625, -0.0625, -0.25, 0.0625}, -- Tanque3
{0.0625, -0.4375, -0.0625, 0.1875, -0.25, 0.0625}, -- Tanque4
{-0.1875, -0.5, 0.125, -0.125, 0, 0.1875}, -- Haste1
{0.125, -0.5, 0.125, 0.1875, 0, 0.1875}, -- Haste2
{-0.1875, -0.5, -0.1875, -0.125, 0, -0.125}, -- Haste3
{0.125, -0.5, -0.1875, 0.1875, 0, -0.125}, -- Haste4
{-0.1875, -0.4375, 0.0625, 0.1875, -0.25, 0.1875}, -- Tank 1
{-0.1875, -0.4375, -0.1875, 0.1875, -0.25, -0.0625}, -- Tank 2
{-0.1875, -0.4375, -0.0625, -0.0625, -0.25, 0.0625}, -- Tank 3
{0.0625, -0.4375, -0.0625, 0.1875, -0.25, 0.0625}, -- Tank 4
{-0.1875, -0.5, 0.125, -0.125, 0, 0.1875}, -- Stem 1
{0.125, -0.5, 0.125, 0.1875, 0, 0.1875}, -- Stem 2
{-0.1875, -0.5, -0.1875, -0.125, 0, -0.125}, -- Stem 3
{0.125, -0.5, -0.1875, 0.1875, 0, -0.125}, -- Stem 4
{-0.25, -0.5, -0.25, 0.25, -0.4375, 0.25}, -- Base
{-0.25, 0, -0.25, 0.25, 0.0625, 0.25}, -- Tampa
{-0.125, 0.0625, -0.125, 0.125, 0.125, 0.125}, -- Tampa2
{-0.0625, -0.25, -0.0625, 0.0625, 0, 0.0625}, -- Vela
{-0.25, 0, -0.25, 0.25, 0.0625, 0.25}, -- Cover
{-0.125, 0.0625, -0.125, 0.125, 0.125, 0.125}, -- Cover 2
{-0.0625, -0.25, -0.0625, 0.0625, 0, 0.0625}, -- Torch
}
}
-- Register node
-- Register node de lamparina
local def_lamp = minetest.serialize({
description = S("Oil Lamp"),
stack_max = 1,
tiles = {
"hardtorch_lamp_wield_cima.png",
"hardtorch_lamp_wield_baixo.png",
"hardtorch_lamp_wield_lado.png",
"hardtorch_lamp_wield_lado.png",
"hardtorch_lamp_wield_lado.png",
"hardtorch_lamp_wield_lado.png"
"hardtorch_lamp_wield_top.png",
"hardtorch_lamp_wield_bottom.png",
"hardtorch_lamp_wield_side.png",
"hardtorch_lamp_wield_side.png",
"hardtorch_lamp_wield_side.png",
"hardtorch_lamp_wield_side.png"
},
drawtype = "nodebox",
paramtype = "light",
@ -89,7 +86,8 @@ local def_lamp = minetest.serialize({
sounds = default.node_sound_wood_defaults(),
})
-- Node-ferramenta
-- Oil Lamp node
-- Nó da lamparina
minetest.register_node("hardtorch:lamp", minetest.deserialize(def_lamp))
minetest.override_item("hardtorch:lamp", {
on_place = function(itemstack, placer, pointed_thing)
@ -103,8 +101,8 @@ minetest.override_item("hardtorch:lamp", {
if not minetest.item_place(itemstack, placer, pointed_thing) then
return itemstack
end
-- Remove item do inventario
-- Remove from inventory
itemstack:take_item()
return itemstack
@ -113,7 +111,8 @@ minetest.override_item("hardtorch:lamp", {
})
-- Node-ferramenta ativo
-- Oil Lamp lit node
-- Nó da lamparina acesa
minetest.register_node("hardtorch:lamp_on", minetest.deserialize(def_lamp))
minetest.override_item("hardtorch:lamp_on", {
description = S("Oil Lamp Lit"),
@ -121,12 +120,12 @@ minetest.override_item("hardtorch:lamp_on", {
paramtype = nil,
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
tiles = {
"hardtorch_lamp_wield_cima.png",
"hardtorch_lamp_wield_baixo.png",
"hardtorch_lamp_wield_lado_on.png",
"hardtorch_lamp_wield_lado_on.png",
"hardtorch_lamp_wield_lado_on.png",
"hardtorch_lamp_wield_lado_on.png"
"hardtorch_lamp_wield_top.png",
"hardtorch_lamp_wield_bottom.png",
"hardtorch_lamp_wield_side_on.png",
"hardtorch_lamp_wield_side_on.png",
"hardtorch_lamp_wield_side_on.png",
"hardtorch_lamp_wield_side_on.png"
},
})
@ -136,24 +135,24 @@ minetest.override_item("hardtorch:lamp_node", {
drop = "hardtorch:lamp",
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
tiles = {
"hardtorch_lamp_cima.png",
"hardtorch_lamp_baixo.png",
"hardtorch_lamp_lado.png",
"hardtorch_lamp_lado.png",
"hardtorch_lamp_lado.png",
"hardtorch_lamp_lado.png"
"hardtorch_lamp_top.png",
"hardtorch_lamp_bottom.png",
"hardtorch_lamp_side.png",
"hardtorch_lamp_side.png",
"hardtorch_lamp_side.png",
"hardtorch_lamp_side.png"
},
node_box = node_nodebox,
})
-- Node ativo
-- Active node
minetest.register_node("hardtorch:lamp_node_active", minetest.deserialize(def_lamp))
minetest.override_item("hardtorch:lamp_node_active", {
light_source = lamp_light_source,
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
tiles = {
"hardtorch_lamp_cima.png",
"hardtorch_lamp_baixo.png",
"hardtorch_lamp_top.png",
"hardtorch_lamp_bottom.png",
tile_anim,
tile_anim,
tile_anim,
@ -163,6 +162,7 @@ minetest.override_item("hardtorch:lamp_node_active", {
})
-- Register Oil Lamp
-- Registrar Lamparina
hardtorch.register_torch("hardtorch:lamp", {
light_source = lamp_light_source,
@ -175,12 +175,13 @@ hardtorch.register_torch("hardtorch:lamp", {
sounds = {
turn_on = {name="hardtorch_click_oil_lamp", gain=0.2},
turn_off = {name="hardtorch_click_oil_lamp", gain=0.2},
water_turn_off = {name="hardtorch_apagando_tocha", gain=0.2},
water_turn_off = {name="hardtorch_turnoff_torch", gain=0.2},
},
fuel = {"hardtorch:oil"},
})
-- Oil Lamp recipe
-- Receita da Lamparina
minetest.register_craft({
output = 'hardtorch:lamp',

View File

@ -1,30 +1,33 @@
--[[
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/>.
Registro de Tochas padrao
Mod HardTorch for Minetest
Copyright (C) 2019 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/>5.
Default Torchs
]]
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Luminosidade da lamparina
-- Torch light
-- Luminosidade da Tocha
local torch_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_torch_light_source") or 11)
-- Noites de durabilidade da tocha
-- Torch durability (in nights)
-- Durabilidade da Tocha (em nights)
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
-- Default torch adjustment
-- Ajuste na tocha padrão
do
minetest.override_item("default:torch", {
-- Change image to player know that need to light it
-- Muda imagem para jogador saber que tem que acendela
inventory_image = "hardtorch_torch_tool_off.png",
wield_image = "hardtorch_torch_tool_off.png",
@ -33,12 +36,14 @@ do
end
-- Register the lit torch like fuel
-- Registra a tocha acessa como um combustivel
hardtorch.register_fuel("hardtorch:torch_on", {
turns = torch_nights,
})
-- Registrar ferramentas
-- Register tool
-- Registrar ferramenta
minetest.register_tool("hardtorch:torch", {
description = S("Torch (used)"),
inventory_image = "hardtorch_torch_tool_off.png",
@ -46,14 +51,15 @@ minetest.register_tool("hardtorch:torch", {
groups = {not_in_creative_inventory = 1},
})
-- Lit version tool
-- Versao acessa da ferramenta
minetest.register_tool("hardtorch:torch_on", {
inventory_image = "hardtorch_torch_tool_on.png",
wield_image = "hardtorch_torch_tool_on_mao.png",
wield_image = "hardtorch_torch_tool_on_wield.png",
groups = {not_in_creative_inventory = 1},
})
-- Registrar tocha
-- Register torch
hardtorch.register_torch("hardtorch:torch", {
light_source = minetest.registered_nodes["default:torch"].light_source,
fuel = {"hardtorch:torch_on"},
@ -63,8 +69,8 @@ hardtorch.register_torch("hardtorch:torch", {
node_wall = "default:torch_wall"
},
sounds = {
turn_on = {name="hardtorch_acendendo_tocha", gain=0.2},
turn_off = {name="hardtorch_apagando_tocha", gain=0.2},
water_turn_off = {name="hardtorch_apagando_tocha", gain=0.2},
turn_on = {name="hardtorch_turnon_torch", gain=0.2},
turn_off = {name="hardtorch_turnoff_torch", gain=0.2},
water_turn_off = {name="hardtorch_turnoff_torch", gain=0.2},
},
})

View File

@ -1,32 +1,31 @@
--[[
Mod HardTorch para Minetest
Mod HardTorch for 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/>.
Registro de Vela (candle) do mod xdecor
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>5.
Candle from xdecor mod
]]
if minetest.registered_nodes["xdecor:candle"] == nil then return end
-- Used for localization
-- Used for localization
local S = minetest.get_translator("hardtorch")
-- Luminosidade da lamparina
-- Candle light
local candle_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_xdecor_candle_light_source") or 7)
-- Noites de durabilidade da tocha
-- Candle durability (in nights)
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
-- Ajuste na vela (candle) do mod xdecor
-- Candle adjustment
do
minetest.override_item("xdecor:candle", {
-- Muda imagem para jogador saber que tem que acendela
-- Change image to player know that need to light it
inventory_image = "xdecor_candle_wield.png",
wield_image = "xdecor_candle_wield.png",
light_source = candle_light_source
@ -34,12 +33,12 @@ do
end
-- Registra a tocha acessa como um combustivel
-- Register the lit torch like fuel
hardtorch.register_fuel("hardtorch:xdecor_candle_on", {
turns = candle_nights,
})
-- Registrar ferramentas
-- Register tool
minetest.register_tool("hardtorch:xdecor_candle", {
description = S("Candle (used)"),
inventory_image = "xdecor_candle_wield.png",
@ -47,14 +46,14 @@ minetest.register_tool("hardtorch:xdecor_candle", {
groups = {not_in_creative_inventory = 1},
})
-- Versao acessa da ferramenta
-- Lit version tool
minetest.register_tool("hardtorch:xdecor_candle_on", {
inventory_image = "xdecor_candle_inv.png",
wield_image = "xdecor_candle_inv.png",
groups = {not_in_creative_inventory = 1},
})
-- Registrar tocha
-- Register Candle
hardtorch.register_torch("hardtorch:xdecor_candle", {
light_source = minetest.registered_nodes["xdecor:candle"].light_source,
fuel = {"hardtorch:xdecor_candle_on"},