|
@ -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)
|
||||||
|
|
43
README.md
|
@ -1,42 +1,39 @@
|
||||||
HardTorch v0.5.6
|
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)
|
[![Download](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)
|
[![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)
|
[![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)
|
[![!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)_
|
## Requirements
|
||||||
* Minetest 0.4.16 (ou superior|_or later_)
|
* Minetest 0.4.16 (or later)
|
||||||
* Mod default
|
* default mod
|
||||||
* Mod fire
|
* fire mod
|
||||||
|
|
||||||
## Configuraçes _(Settings)_
|
## 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).
|
||||||
_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)_
|
## 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
|
||||||
_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)
|
BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)
|
||||||
|
|
||||||
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0)
|
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0)
|
||||||
hardtorch_apagando_tocha.1.ogg
|
hardtorch_turnoff_torch.1.ogg
|
||||||
hardtorch_apagando_tocha.2.ogg
|
hardtorch_turnoff_torch.2.ogg
|
||||||
hardtorch_apagando_tocha.3.ogg
|
hardtorch_turnoff_torch.3.ogg
|
||||||
|
|
||||||
Jojikiba (CC BY-SA 3.0)
|
Jojikiba (CC BY-SA 3.0)
|
||||||
hardtorch_acendendo_tocha.ogg (editado por Lunovox)
|
hardtorch_turnon_torch.ogg (remixed by Lunovox)
|
||||||
|
|
||||||
|
|
22
api.lua
|
@ -1,36 +1,40 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
API
|
API
|
||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- Global Table
|
||||||
-- Tabela Global
|
-- Tabela Global
|
||||||
hardtorch.registered_torchs = {}
|
hardtorch.registered_torchs = {}
|
||||||
|
|
||||||
|
-- Register torch
|
||||||
-- Registrar tocha
|
-- Registrar tocha
|
||||||
hardtorch.register_torch = function(name, def)
|
hardtorch.register_torch = function(name, def)
|
||||||
|
|
||||||
hardtorch.registered_torchs[name] = def
|
hardtorch.registered_torchs[name] = def
|
||||||
|
|
||||||
|
-- Consolidate data
|
||||||
-- Consolidar dados
|
-- Consolidar dados
|
||||||
hardtorch.registered_torchs[name].sounds = def.sounds or {}
|
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)
|
hardtorch.register_tool(name, def)
|
||||||
|
|
||||||
|
-- Register node
|
||||||
-- Registrar node
|
-- Registrar node
|
||||||
hardtorch.register_node(name, def)
|
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)
|
minetest.register_on_joinplayer(function(player)
|
||||||
if hardtorch.find_item(player, name.."_on") == true then
|
if hardtorch.find_item(player, name.."_on") == true then
|
||||||
hardtorch.apagar_tocha(player, name)
|
hardtorch.turnoff_torch(player, name)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hardtorch",
|
"name": "hardtorch",
|
||||||
"description": "Tochas realistas para Minetest",
|
"description": "Realistic torchs from Minetest",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"torch",
|
"torch",
|
||||||
"tochas",
|
"tochas",
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Metodos comuns
|
|
||||||
|
|
||||||
|
Common Methods
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
|
-- Play turn on torch sound
|
||||||
-- Tocar som de acender tocha
|
-- 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
|
if hardtorch.registered_torchs[torchname].sounds.turn_on then
|
||||||
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.turn_on.name, {
|
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.turn_on.name, {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
|
@ -23,8 +22,9 @@ hardtorch.som_acender = function(pos, torchname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Play turn off torch sound
|
||||||
-- Tocar som de apagar tocha
|
-- 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
|
if hardtorch.registered_torchs[torchname].sounds.turn_off then
|
||||||
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.turn_off.name, {
|
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.turn_off.name, {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
|
@ -35,8 +35,9 @@ hardtorch.som_apagar = function(pos, torchname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Play turn off torch by water sound
|
||||||
-- Tocar som de apagar tocha pela agua
|
-- 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
|
if hardtorch.registered_torchs[torchname].sounds.water_turn_off then
|
||||||
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.water_turn_off.name, {
|
minetest.sound_play(hardtorch.registered_torchs[torchname].sounds.water_turn_off.name, {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
|
@ -47,12 +48,14 @@ hardtorch.som_apagar_por_agua = function(pos, torchname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Calculate remaining time of a node
|
||||||
-- Calcular tempo restante de um node
|
-- Calcular tempo restante de um node
|
||||||
hardtorch.get_node_timeout = function(pos)
|
hardtorch.get_node_timeout = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local torchname = hardtorch.registered_nodes[minetest.get_node(pos).name]
|
local torchname = hardtorch.registered_nodes[minetest.get_node(pos).name]
|
||||||
local fuel = meta:get_string("hardtorch_fuel")
|
local fuel = meta:get_string("hardtorch_fuel")
|
||||||
-- Verifica combustivel
|
|
||||||
|
-- Check fuel
|
||||||
if fuel == "" then fuel = hardtorch.registered_torchs[torchname].fuel[1] end
|
if fuel == "" then fuel = hardtorch.registered_torchs[torchname].fuel[1] end
|
||||||
local wear = meta:get_int("hardtorch_wear")
|
local wear = meta:get_int("hardtorch_wear")
|
||||||
local fulltime = hardtorch.registered_fuels[fuel].time
|
local fulltime = hardtorch.registered_fuels[fuel].time
|
||||||
|
@ -60,12 +63,15 @@ hardtorch.get_node_timeout = function(pos)
|
||||||
return fulltime-math.floor(time)
|
return fulltime-math.floor(time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Calculate wear on a node
|
||||||
-- Calcular desgaste de um node
|
-- Calcular desgaste de um node
|
||||||
hardtorch.get_node_wear = function(pos)
|
hardtorch.get_node_wear = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local fuel = meta:get_string("hardtorch_fuel")
|
local fuel = meta:get_string("hardtorch_fuel")
|
||||||
local torchname = hardtorch.registered_nodes[minetest.get_node(pos).name]
|
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
|
if fuel == "" then fuel = hardtorch.registered_torchs[torchname].fuel[1] end
|
||||||
local fulltime = hardtorch.registered_fuels[fuel].time
|
local fulltime = hardtorch.registered_fuels[fuel].time
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
@ -75,8 +81,8 @@ hardtorch.get_node_wear = function(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Atualizar um itemstack no inventario do jogador
|
-- Update itemstack (default method 'set_stack' cannot update with an empty stack)
|
||||||
-- (metodo padrão set_stack() não consegue atualizar com stack vazio)
|
-- Atualiza itemstack (metodo padrão 'set_stack' não consegue atualizar com stack vazio)
|
||||||
hardtorch.update_inv = function(player, list, i, stack)
|
hardtorch.update_inv = function(player, list, i, stack)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local itemlist = inv:get_list(list)
|
local itemlist = inv:get_list(list)
|
||||||
|
@ -85,7 +91,8 @@ hardtorch.update_inv = function(player, list, i, stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Verificar impedimento no local proximo da tocha
|
-- Check nodes near torch
|
||||||
|
-- Verificar blocos perto da tocha
|
||||||
hardtorch.check_torch_area = function(pos)
|
hardtorch.check_torch_area = function(pos)
|
||||||
for _,p in ipairs({
|
for _,p in ipairs({
|
||||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||||
|
@ -103,13 +110,16 @@ hardtorch.check_torch_area = function(pos)
|
||||||
end
|
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)
|
hardtorch.find_and_get_item = function(player, itemname)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
-- Verifica cada um dos itens
|
|
||||||
|
-- Check each list name
|
||||||
for list_name,list in pairs(inv:get_lists()) do
|
for list_name,list in pairs(inv:get_lists()) do
|
||||||
|
|
||||||
|
-- Check each item
|
||||||
for i,item in ipairs(list) do
|
for i,item in ipairs(list) do
|
||||||
-- Troca pela tocha apagada
|
|
||||||
if item:get_name() == itemname then
|
if item:get_name() == itemname then
|
||||||
return list_name, i, item
|
return list_name, i, item
|
||||||
end
|
end
|
||||||
|
@ -118,10 +128,12 @@ hardtorch.find_and_get_item = function(player, itemname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Encontrar tocha acessa no inventario
|
-- Find item on inventory
|
||||||
|
-- Busca item no inventario
|
||||||
hardtorch.find_item = function(player, itemname)
|
hardtorch.find_item = function(player, itemname)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
-- Verifica em todas listas de inventario
|
|
||||||
|
-- Check each list name
|
||||||
for listname,list in pairs(inv:get_lists()) do
|
for listname,list in pairs(inv:get_lists()) do
|
||||||
if inv:contains_item(listname, itemname) then
|
if inv:contains_item(listname, itemname) then
|
||||||
return true
|
return true
|
||||||
|
@ -131,7 +143,8 @@ hardtorch.find_item = function(player, itemname)
|
||||||
end
|
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)
|
hardtorch.get_fuel_stack = function(player, torchname)
|
||||||
for _,fuelname in ipairs(hardtorch.registered_torchs[torchname].fuel) do
|
for _,fuelname in ipairs(hardtorch.registered_torchs[torchname].fuel) do
|
||||||
if hardtorch.find_item(player, fuelname) then
|
if hardtorch.find_item(player, fuelname) then
|
||||||
|
@ -141,13 +154,14 @@ hardtorch.get_fuel_stack = function(player, torchname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- HUD element default light
|
||||||
-- Elemento HUD luz padrao
|
-- Elemento HUD luz padrao
|
||||||
hardtorch.hud_element = {
|
hardtorch.hud_element = {
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
position = {x=0.1, y=1.1},
|
position = {x=0.1, y=1.1},
|
||||||
name = "hardtorch_luz",
|
name = "hardtorch_light",
|
||||||
scale = {x=4, y=4},
|
scale = {x=4, y=4},
|
||||||
text = "hardtorch_luz.png",
|
text = "hardtorch_light.png",
|
||||||
number = 2,
|
number = 2,
|
||||||
item = 3,
|
item = 3,
|
||||||
direction = 0,
|
direction = 0,
|
||||||
|
@ -157,22 +171,25 @@ hardtorch.hud_element = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Adicionar luz do hud
|
-- Add light on HUD
|
||||||
hardtorch.adicionar_luz_hud = function(player, torchname)
|
-- Adicionar luz no HUD
|
||||||
hardtorch.em_loop[player:get_player_name()].hud_id = player:hud_add(hardtorch.hud_element)
|
hardtorch.add_light_hud = function(player, torchname)
|
||||||
|
hardtorch.in_loop[player:get_player_name()].hud_id = player:hud_add(hardtorch.hud_element)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Remover luz do hud
|
-- Remove light from HUD
|
||||||
hardtorch.remover_luz_hud = function(player)
|
-- Remover luz do HUD
|
||||||
|
hardtorch.remove_light_hud = function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if hardtorch.em_loop[name] and hardtorch.em_loop[name].hud_id then
|
if hardtorch.in_loop[name] and hardtorch.in_loop[name].hud_id then
|
||||||
player:hud_remove(hardtorch.em_loop[name].hud_id)
|
player:hud_remove(hardtorch.in_loop[name].hud_id)
|
||||||
end
|
end
|
||||||
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)
|
hardtorch.check_light_number = function(n)
|
||||||
if not n then
|
if not n then
|
||||||
return 1
|
return 1
|
|
@ -1 +1 @@
|
||||||
Tochas realistas (Realistic torchs)
|
Realistic torchs
|
||||||
|
|
|
@ -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)
|
|
|
@ -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)
|
20
fuel.lua
|
@ -1,18 +1,18 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Combustiveis
|
|
||||||
|
|
||||||
|
Fuel
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- Global Table
|
||||||
-- Tabela Global
|
-- Tabela Global
|
||||||
hardtorch.registered_fuels = {}
|
hardtorch.registered_fuels = {}
|
||||||
|
|
||||||
|
-- Register Fuel
|
||||||
-- Registrar Combustivel
|
-- Registrar Combustivel
|
||||||
hardtorch.register_fuel = function(name, def)
|
hardtorch.register_fuel = function(name, def)
|
||||||
|
|
||||||
|
@ -23,16 +23,18 @@ hardtorch.register_fuel = function(name, def)
|
||||||
registro.time = def.turns * hardtorch.night_time
|
registro.time = def.turns * hardtorch.night_time
|
||||||
registro.loop_wear = (65535/registro.time)*2
|
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
|
-- Sobreescreve on_place para evitar reparos no combustivel em ferramentas
|
||||||
if minetest.registered_tools[name] then
|
if minetest.registered_tools[name] then
|
||||||
hardtorch.registered_fuels[name].old_on_place = minetest.registered_tools[name].on_place
|
hardtorch.registered_fuels[name].old_on_place = minetest.registered_tools[name].on_place
|
||||||
hardtorch.registered_fuels[name].on_place = function(itemstack, placer, pointed_thing)
|
hardtorch.registered_fuels[name].on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
|
-- Check for avoidable nodes
|
||||||
-- Verifica nodes evitaveis
|
-- 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
|
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
|
if n == nn then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
78
init.lua
|
@ -1,34 +1,44 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Inicializador de scripts
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
|
-- Global Table
|
||||||
-- Tabela Global
|
-- Tabela Global
|
||||||
hardtorch = {}
|
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
|
-- Requerer fonte de fogo para acender tocha
|
||||||
hardtorch.torch_lighter = (minetest.settings:get("hardtorch_torch_lighter") == "true") or false
|
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
|
-- Nodes para evitar ao colocar tochas
|
||||||
hardtorch.evitar_tool_on_place = {}
|
hardtorch.not_place_torch_on = {}
|
||||||
-- Mod Anvil
|
|
||||||
|
-- Anvil Mod
|
||||||
if minetest.get_modpath("anvil") then
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Fixed time for a night
|
||||||
-- Tempo fixo de duração de uma noite
|
-- Tempo fixo de duração de uma noite
|
||||||
hardtorch.night_time = tonumber(minetest.settings:get("hardtorch_fixed_night_time") or 0)
|
hardtorch.night_time = tonumber(minetest.settings:get("hardtorch_fixed_night_time") or 0)
|
||||||
if hardtorch.night_time == 0 then
|
if hardtorch.night_time == 0 then
|
||||||
|
@ -39,48 +49,58 @@ if hardtorch.night_time == 0 then
|
||||||
hardtorch.night_time = (12*60*60)/time_speed
|
hardtorch.night_time = (12*60*60)/time_speed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Notify load
|
||||||
-- Notificador de Inicializador
|
-- Notificador de Inicializador
|
||||||
local notificar = function(msg)
|
local notify = function(msg)
|
||||||
if minetest.settings:get("log_mods") then
|
if minetest.settings:get("log_mods") then
|
||||||
minetest.debug("[HardTorch]"..msg)
|
minetest.debug("[HardTorch] "..msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Modpath
|
-- Modpath
|
||||||
local modpath = minetest.get_modpath("hardtorch")
|
local modpath = minetest.get_modpath("hardtorch")
|
||||||
|
|
||||||
|
|
||||||
-- Carregar scripts
|
-- Carregar scripts
|
||||||
notificar("Carregando...")
|
notify("Loading...")
|
||||||
-- Metodos gerais
|
|
||||||
dofile(modpath.."/comum.lua")
|
-- API
|
||||||
dofile(modpath.."/luz.lua")
|
dofile(modpath.."/common.lua")
|
||||||
|
dofile(modpath.."/light.lua")
|
||||||
dofile(modpath.."/tool.lua")
|
dofile(modpath.."/tool.lua")
|
||||||
dofile(modpath.."/node.lua")
|
dofile(modpath.."/node.lua")
|
||||||
dofile(modpath.."/lighter.lua")
|
dofile(modpath.."/lighter.lua")
|
||||||
dofile(modpath.."/fuel.lua")
|
dofile(modpath.."/fuel.lua")
|
||||||
dofile(modpath.."/api.lua")
|
dofile(modpath.."/api.lua")
|
||||||
|
|
||||||
|
-- Content
|
||||||
dofile(modpath.."/oil.lua")
|
dofile(modpath.."/oil.lua")
|
||||||
dofile(modpath.."/torchs/torch.lua")
|
dofile(modpath.."/torchs/torch.lua")
|
||||||
dofile(modpath.."/torchs/lamp.lua")
|
dofile(modpath.."/torchs/lamp.lua")
|
||||||
dofile(modpath.."/torchs/xdecor_candle.lua")
|
dofile(modpath.."/torchs/xdecor_candle.lua")
|
||||||
notificar("[OK]!")
|
|
||||||
|
notify("OK!")
|
||||||
|
|
||||||
|
|
||||||
|
-- Preset
|
||||||
-- Pré ajustes
|
-- Pré ajustes
|
||||||
|
|
||||||
|
-- Lighter Flint and Steel
|
||||||
-- Acendedor de pederneira
|
-- Acendedor de pederneira
|
||||||
hardtorch.register_lighter("fire:flint_and_steel", {
|
hardtorch.register_lighter("fire:flint_and_steel", {
|
||||||
wear_by_use = 1000
|
wear_by_use = 1000
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Fire source nodes
|
||||||
-- Nodes fonte de fogo
|
-- Nodes fonte de fogo
|
||||||
hardtorch.fontes_de_fogo["default:furnace_active"] = true
|
hardtorch.fire_sources["default:furnace_active"] = true
|
||||||
hardtorch.fontes_de_fogo["default:lava_flowing"] = true
|
hardtorch.fire_sources["default:lava_flowing"] = true
|
||||||
hardtorch.fontes_de_fogo["default:lava_source"] = true
|
hardtorch.fire_sources["default:lava_source"] = true
|
||||||
hardtorch.fontes_de_fogo["fire:basic_flame"] = true
|
hardtorch.fire_sources["fire:basic_flame"] = true
|
||||||
hardtorch.fontes_de_fogo["fire:permanent_flame"] = true
|
hardtorch.fire_sources["fire:permanent_flame"] = true
|
||||||
|
|
||||||
|
-- Campfire Mod
|
||||||
if minetest.get_modpath("campfire") then
|
if minetest.get_modpath("campfire") then
|
||||||
hardtorch.fontes_de_fogo["campfire:campfire_active"] = true
|
hardtorch.fire_sources["campfire:campfire_active"] = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -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,
|
||||||
|
})
|
14
lighter.lua
|
@ -1,18 +1,18 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Acendedores
|
|
||||||
|
|
||||||
|
Lighter
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- Global Table
|
||||||
-- Tabela global
|
-- Tabela global
|
||||||
hardtorch.registered_lighters = {}
|
hardtorch.registered_lighters = {}
|
||||||
|
|
||||||
|
-- Register lighter
|
||||||
-- Registrar Acendedor
|
-- Registrar Acendedor
|
||||||
hardtorch.register_lighter = function(name, def)
|
hardtorch.register_lighter = function(name, def)
|
||||||
hardtorch.registered_lighters[name] = def
|
hardtorch.registered_lighters[name] = def
|
||||||
|
|
122
luz.lua
|
@ -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
|
@ -1,70 +1,76 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Nodes
|
Nodes
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- Registered nodes
|
||||||
-- Nodes registrados
|
-- Nodes registrados
|
||||||
hardtorch.registered_nodes = {}
|
hardtorch.registered_nodes = {}
|
||||||
|
|
||||||
|
-- Register torch node
|
||||||
-- Registrar Node de tocha
|
-- Registrar Node de tocha
|
||||||
hardtorch.register_node = function(torchname, def)
|
hardtorch.register_node = function(torchname, def)
|
||||||
|
|
||||||
for nt,nn in pairs(def.nodes) do
|
for nt,nn in pairs(def.nodes) do
|
||||||
hardtorch.registered_nodes[nn] = torchname
|
hardtorch.registered_nodes[nn] = torchname
|
||||||
if def.nodes.fire_source ~= false then
|
if def.nodes.fire_source ~= false then
|
||||||
hardtorch.fontes_de_fogo[nn] = true
|
hardtorch.fire_sources[nn] = true
|
||||||
end
|
end
|
||||||
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)
|
local on_dig = function(pos, node, digger)
|
||||||
if not hardtorch.registered_nodes[node.name] then return end
|
if not hardtorch.registered_nodes[node.name] then return end
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = digger:get_inventory()
|
local inv = digger:get_inventory()
|
||||||
|
|
||||||
-- Calcula desgaste
|
-- Calculate wear
|
||||||
local wear = hardtorch.get_node_wear(pos)
|
local wear = hardtorch.get_node_wear(pos)
|
||||||
local itemstack = {name=torchname, count=1}
|
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
|
if torchname.."_on" == meta:get_string("hardtorch_fuel") then
|
||||||
itemstack.wear = wear
|
itemstack.wear = wear
|
||||||
|
torch_is_fuel = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Torna acessa caso ainda nao tenha nenhuma (sem loop)
|
-- Keep torch lit if possible
|
||||||
if not hardtorch.em_loop[digger:get_player_name()] then
|
-- Deixa tocha acesa se possivel
|
||||||
|
if not hardtorch.in_loop[digger:get_player_name()] then
|
||||||
itemstack.name = torchname.."_on"
|
itemstack.name = torchname.."_on"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Checks if torch fits in inventory
|
||||||
-- Verifica se tocha cabe no inventario
|
-- Verifica se tocha cabe no inventario
|
||||||
if inv:room_for_item("main", itemstack) then
|
if inv:room_for_item("main", itemstack) then
|
||||||
|
|
||||||
-- Coloca no inventario
|
|
||||||
inv:add_item("main", itemstack)
|
inv:add_item("main", itemstack)
|
||||||
|
|
||||||
|
-- Lights with loop if added previously lit
|
||||||
-- Acende com loop caso adicinou acesa anteriormente
|
-- 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")
|
local list, i, itemstack = hardtorch.find_and_get_item(digger, torchname.."_on")
|
||||||
itemstack:set_name(torchname)
|
itemstack:set_name(torchname)
|
||||||
itemstack = hardtorch.acender_tocha(itemstack, digger)
|
itemstack = hardtorch.turnon_torch(itemstack, digger)
|
||||||
inv:set_stack(list, i, itemstack)
|
inv:set_stack(list, i, itemstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
-- Dropa no local
|
-- Drop torch
|
||||||
minetest.add_item(pos, itemstack)
|
minetest.add_item(pos, itemstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Checks if fuel fits in inventory
|
||||||
-- Verifica se combustivel cabe no inventario
|
-- 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}
|
local fuelstack = {name=meta:get_string("hardtorch_fuel"), count=1, wear=wear}
|
||||||
|
|
||||||
if inv:room_for_item("main", fuelstack) then
|
if inv:room_for_item("main", fuelstack) then
|
||||||
|
@ -72,72 +78,89 @@ hardtorch.register_node = function(torchname, def)
|
||||||
-- Coloca no inventario
|
-- Coloca no inventario
|
||||||
inv:add_item("main", fuelstack)
|
inv:add_item("main", fuelstack)
|
||||||
else
|
else
|
||||||
-- Dropa no local
|
-- Drop fuel
|
||||||
minetest.add_item(pos, fuelstack)
|
minetest.add_item(pos, fuelstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
end
|
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)
|
local on_use = function(itemstack, player, pointed_thing)
|
||||||
if not hardtorch.registered_nodes[itemstack:get_name()] then return end
|
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()
|
local inv = player:get_inventory()
|
||||||
|
|
||||||
|
-- Localize the item on inventory
|
||||||
-- Localiza o item no iventario
|
-- Localiza o item no iventario
|
||||||
local list, i = player:get_wield_list(), player:get_wield_index()
|
local list, i = player:get_wield_list(), player:get_wield_index()
|
||||||
local itemstack2 = inv:get_stack(list, i)
|
local itemstack2 = inv:get_stack(list, i)
|
||||||
if itemstack:to_string() ~= itemstack2:to_string() then
|
if itemstack:to_string() ~= itemstack2:to_string() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Troca o item pela ferramenta
|
-- Replace item
|
||||||
itemstack:replace({name=torchname, count=1, wear=0, metadata=""})
|
itemstack:replace({name=torchname, count=1, wear=0, metadata=""})
|
||||||
inv:set_stack(list, i, itemstack)
|
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)
|
-- Caso tenha sobra tenta colocar no inventario, ou joga no chão (com aviso sonoro e textual)
|
||||||
if sobra > 0 then
|
if leftover > 0 then
|
||||||
if inv:room_for_item("main", def.nodes.node.." "..sobra) then
|
|
||||||
-- Coloca no inventario
|
-- Put in inventory
|
||||||
inv:add_item("main", def.nodes.node.." "..sobra)
|
if inv:room_for_item("main", def.nodes.node.." "..leftover) then
|
||||||
|
inv:add_item("main", def.nodes.node.." "..leftover)
|
||||||
|
|
||||||
|
-- Drop
|
||||||
else
|
else
|
||||||
-- Coloca a tocha no inventario para poder dropa-la
|
-- Set torchs in inveotory to drop
|
||||||
inv:set_stack(list, i, def.nodes.node.." "..sobra)
|
-- 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())
|
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)
|
inv:set_stack(list, i, itemstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
itemstack:set_name(torchname) -- restaura nome da tocha
|
-- Restore torch name
|
||||||
|
-- Restaura nome da tocha
|
||||||
|
itemstack:set_name(torchname)
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
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)
|
local after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
if not hardtorch.registered_nodes[minetest.get_node(pos).name] then return end
|
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)
|
local timer = minetest.get_node_timer(pos)
|
||||||
if timer:is_started() ~= true then
|
if timer:is_started() ~= true then
|
||||||
|
|
||||||
|
-- Set initial wear if necessary
|
||||||
-- Define desgaste inicial caso necessario
|
-- Define desgaste inicial caso necessario
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if meta:get_string("hardtorch_fuel") == "" then
|
if meta:get_string("hardtorch_fuel") == "" then
|
||||||
meta:set_string("hardtorch_fuel", def.fuel[1])
|
meta:set_string("hardtorch_fuel", def.fuel[1])
|
||||||
meta:set_int("hardtorch_wear", 0)
|
meta:set_int("hardtorch_wear", 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Starts counting to end fire according to set wear
|
||||||
-- Inicia contagem para acabar fogo de acordo com desgaste definido
|
-- Inicia contagem para acabar fogo de acordo com desgaste definido
|
||||||
timer:start(hardtorch.get_node_timeout(pos))
|
timer:start(hardtorch.get_node_timeout(pos))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Remove torch when fire end
|
||||||
-- Remove tocha quando fogo acabar
|
-- Remove tocha quando fogo acabar
|
||||||
local on_timer = function(pos, elapsed)
|
local on_timer = function(pos, elapsed)
|
||||||
if not hardtorch.registered_nodes[minetest.get_node(pos).name] then return end
|
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,
|
on_timer=on_timer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Prevent normal placement in special cases
|
||||||
-- Impedir colocação normal em casos especiais
|
-- Impedir colocação normal em casos especiais
|
||||||
if hardtorch.torch_lighter then
|
if hardtorch.torch_lighter then
|
||||||
node_torch_def.on_place = function(itemstack, placer, pointed_thing)
|
node_torch_def.on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
@ -173,15 +197,16 @@ hardtorch.register_node = function(torchname, def)
|
||||||
end
|
end
|
||||||
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, node_torch_def)
|
||||||
minetest.override_item(def.nodes.node_ceiling or 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)
|
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
|
-- Apagar tochas em contato com agua
|
||||||
minetest.register_abm({
|
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},
|
nodenames = {def.nodes.node, def.nodes.node_ceiling, def.nodes.node_wall},
|
||||||
neighbors = {"group:water"},
|
neighbors = {"group:water"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
|
@ -190,7 +215,7 @@ hardtorch.register_node = function(torchname, def)
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if hardtorch.check_torch_area(pos) == false then
|
if hardtorch.check_torch_area(pos) == false then
|
||||||
local wear = hardtorch.get_node_wear(pos)
|
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.remove_node(pos)
|
||||||
minetest.add_item(pos, def.drop_on_water or {name=torchname, wear=wear})
|
minetest.add_item(pos, def.drop_on_water or {name=torchname, wear=wear})
|
||||||
end
|
end
|
||||||
|
|
27
oil.lua
|
@ -1,38 +1,37 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
Oil
|
||||||
Registro de Oleo
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
-- Used for localization
|
-- Used for localization
|
||||||
|
|
||||||
local S = minetest.get_translator("hardtorch")
|
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))
|
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
|
if oil_nights <= 0 then oil_nights = 1.2 end
|
||||||
|
|
||||||
|
-- Oil
|
||||||
-- Oleo de lamparina
|
-- Oleo
|
||||||
minetest.register_tool("hardtorch:oil", {
|
minetest.register_tool("hardtorch:oil", {
|
||||||
description = S("Oil"),
|
description = S("Oil"),
|
||||||
inventory_image = "hardtorch_oil.png",
|
inventory_image = "hardtorch_oil.png",
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Register fuel
|
||||||
-- Registrar combustivel
|
-- Registrar combustivel
|
||||||
hardtorch.register_fuel("hardtorch:oil", {
|
hardtorch.register_fuel("hardtorch:oil", {
|
||||||
turns = oil_nights,
|
turns = oil_nights,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Oil recipes
|
||||||
-- Receitas para oleo
|
-- Receitas para oleo
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'hardtorch:oil',
|
output = 'hardtorch:oil',
|
||||||
|
|
|
@ -1,31 +1,33 @@
|
||||||
# Configurações aplicaveis para o menu gráfico
|
# 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.
|
# 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.
|
# 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)
|
# 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)
|
# 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.
|
# 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.
|
# Fixed time (in seconds) that lasts one night.
|
||||||
# This will ignore the true duration of the night in the game.
|
# This will ignore the true duration of the night in the game.
|
||||||
# Set 0 to disable.
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 449 B |
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 438 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 75 B |
285
tool.lua
|
@ -1,99 +1,119 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
Tool
|
||||||
Ferramentas
|
|
||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
-- Used for localization
|
-- Used for localization
|
||||||
|
|
||||||
local S = minetest.get_translator("hardtorch")
|
local S = minetest.get_translator("hardtorch")
|
||||||
|
|
||||||
|
|
||||||
|
-- Turn on torch
|
||||||
-- Acender tocha
|
-- Acender tocha
|
||||||
hardtorch.acender_tocha = function(itemstack, player)
|
hardtorch.turnon_torch = function(itemstack, player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local torchname = itemstack:get_name()
|
local torchname = itemstack:get_name()
|
||||||
itemstack:set_name(torchname.."_on")
|
itemstack:set_name(torchname.."_on")
|
||||||
|
|
||||||
-- Verifica se ja esta acessa (evitar loop duplo)
|
-- Check if it is already lit (avoid double loop)
|
||||||
if not hardtorch.em_loop[name] then
|
-- Verifica se ja esta acesa (evitar loop duplo)
|
||||||
hardtorch.em_loop[name] = {
|
if not hardtorch.in_loop[name] then
|
||||||
|
hardtorch.in_loop[name] = {
|
||||||
lpos = hardtorch.get_lpos(player),
|
lpos = hardtorch.get_lpos(player),
|
||||||
torchname = torchname,
|
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)
|
-- Inicia loop de tocha (atraso para dar tempo de atualizar item no inventario)
|
||||||
minetest.after(0.3, hardtorch.loop_tocha, name, torchname)
|
minetest.after(0.3, hardtorch.torch_loop, name, torchname)
|
||||||
-- Inicia loop de luz
|
|
||||||
hardtorch.loop_luz(name, torchname)
|
-- Start light loop
|
||||||
-- Som
|
hardtorch.light_loop(name, torchname)
|
||||||
hardtorch.som_acender(player:getpos(), torchname)
|
|
||||||
|
-- Play sound
|
||||||
|
hardtorch.turnon_sound(player:getpos(), torchname)
|
||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Apaga todas as tochas que um jogador possui
|
-- Turn off torchs
|
||||||
hardtorch.apagar_tocha = function(player, torchname)
|
-- Apagar tochas
|
||||||
-- Remover luz do hud
|
hardtorch.turnoff_torch = function(player, torchname)
|
||||||
hardtorch.remover_luz_hud(player)
|
|
||||||
|
|
||||||
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
|
torchname = torchname or loop.torchname
|
||||||
|
|
||||||
-- Pega a tocha
|
-- Take torch
|
||||||
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
|
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
|
||||||
if list then
|
if list then
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
-- Coloca no lugar
|
-- Set torch off
|
||||||
itemstack:set_name(torchname)
|
itemstack:set_name(torchname)
|
||||||
inv:set_stack(list, i, itemstack)
|
inv:set_stack(list, i, itemstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Inicia loop de verificação apos acender tocha
|
-- Start torch loop (for mantain torch working)
|
||||||
hardtorch.loop_tocha = function(name, torchname)
|
-- Inicia loop da tocha (para manter tocha funcionando)
|
||||||
-- Verifica se ja iniciou loop
|
hardtorch.torch_loop = function(name, torchname)
|
||||||
if not hardtorch.em_loop[name] then return end
|
|
||||||
-- Verifica jogador
|
-- 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)
|
local player = minetest.get_player_by_name(name)
|
||||||
if not player then end
|
if not player then end
|
||||||
|
|
||||||
local def = hardtorch.registered_torchs[torchname]
|
local def = hardtorch.registered_torchs[torchname]
|
||||||
local loop = hardtorch.em_loop[name]
|
local loop = hardtorch.in_loop[name]
|
||||||
|
|
||||||
-- Verifica tocha
|
|
||||||
|
-- Torch
|
||||||
|
-- Tocha
|
||||||
|
|
||||||
|
-- Check torch
|
||||||
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
|
local list, i, itemstack = hardtorch.find_and_get_item(player, torchname.."_on")
|
||||||
if not itemstack then
|
if not itemstack then
|
||||||
-- Encerra loop
|
-- Finish loop
|
||||||
hardtorch.apagar_tocha(player, torchname)
|
hardtorch.turnoff_torch(player, torchname)
|
||||||
hardtorch.em_loop[name] = nil
|
hardtorch.in_loop[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Verifica se tem lugar para a luz
|
-- Check air for torch light
|
||||||
|
-- Verifica ar para luz da tocha
|
||||||
do
|
do
|
||||||
local nn = minetest.get_node(hardtorch.get_lpos(player)).name
|
local nn = minetest.get_node(hardtorch.get_lpos(player)).name
|
||||||
if nn ~= "air" and not string.match(nn, "hardtorch:luz_") then
|
if nn ~= "air" and not string.match(nn, "hardtorch:light_") then
|
||||||
-- Encerra loop
|
-- Finish loop
|
||||||
hardtorch.apagar_tocha(player, torchname)
|
hardtorch.turnoff_torch(player, torchname)
|
||||||
hardtorch.em_loop[name] = nil
|
hardtorch.in_loop[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Fuel
|
||||||
-- Combustivel
|
-- Combustivel
|
||||||
|
|
||||||
|
-- Update fuel wear
|
||||||
-- Atualiza combustivel em uso
|
-- Atualiza combustivel em uso
|
||||||
local inv = player:get_inventory()
|
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
|
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()}
|
loop.fuel = {list=listfuel, i=indexfuel, name=itemfuel:get_name()}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Consome o Combustivel
|
|
||||||
|
-- Add wear to fuel item
|
||||||
|
-- Consome o Combustivel no inventario
|
||||||
if loop.fuel then
|
if loop.fuel then
|
||||||
local item = inv:get_stack(loop.fuel.list, loop.fuel.i)
|
local item = inv:get_stack(loop.fuel.list, loop.fuel.i)
|
||||||
item:add_wear(hardtorch.registered_fuels[loop.fuel.name].loop_wear)
|
item:add_wear(hardtorch.registered_fuels[loop.fuel.name].loop_wear)
|
||||||
inv:set_stack(loop.fuel.list, loop.fuel.i, item)
|
inv:set_stack(loop.fuel.list, loop.fuel.i, item)
|
||||||
else
|
else
|
||||||
|
-- "Without fuel" warning
|
||||||
-- Aviso de "sem combustivel"
|
-- Aviso de "sem combustivel"
|
||||||
if torchname ~= def.fuel[1] then
|
if torchname ~= def.fuel[1] then
|
||||||
minetest.chat_send_player(player:get_player_name(), S("Without fuel"))
|
minetest.chat_send_player(player:get_player_name(), S("Without fuel"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Finish loop
|
||||||
-- Encerra loop
|
-- Encerra loop
|
||||||
hardtorch.apagar_tocha(player, torchname)
|
hardtorch.turnoff_torch(player, torchname)
|
||||||
hardtorch.em_loop[name] = nil
|
hardtorch.in_loop[name] = nil
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Checks if fuel runs out during loop
|
||||||
-- Verifica se acabou a tocha durante o loop
|
-- Verifica se acabou o combustivel durante o loop
|
||||||
if itemstack:is_empty() then
|
if itemstack:is_empty() then
|
||||||
|
-- Finish loop
|
||||||
-- Encerra loop
|
-- Encerra loop
|
||||||
hardtorch.apagar_tocha(player, torchname)
|
hardtorch.turnoff_torch(player, torchname)
|
||||||
hardtorch.em_loop[name] = nil
|
hardtorch.in_loop[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check if HUD element has been added
|
||||||
-- Verifica se luz do hud foi criada
|
-- Verifique se o elemento HUD foi adicionado
|
||||||
if not loop.hud_id
|
if not loop.hud_id
|
||||||
or not player:hud_get(loop.hud_id)
|
or not player:hud_get(loop.hud_id)
|
||||||
then
|
then
|
||||||
hardtorch.adicionar_luz_hud(player, torchname)
|
hardtorch.add_light_hud(player, torchname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Wait for next loop
|
||||||
-- Prepara para proximo loop
|
-- Aguarda para proximo loop
|
||||||
minetest.after(2, hardtorch.loop_tocha, name, torchname)
|
minetest.after(2, hardtorch.torch_loop, name, torchname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Register tool
|
||||||
-- Registra as ferramentas
|
-- Registrar ferramenta
|
||||||
hardtorch.register_tool = function(torchname, def)
|
hardtorch.register_tool = function(torchname, def)
|
||||||
|
|
||||||
|
-- Adjust the created tool
|
||||||
-- Ajusta a ferramenta criada
|
-- Ajusta a ferramenta criada
|
||||||
minetest.override_item(torchname, {
|
minetest.override_item(torchname, {
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
if itemstack:get_name() ~= torchname then return end
|
if itemstack:get_name() ~= torchname then return end
|
||||||
|
|
||||||
-- Verifica se ja tem uma tocha acessa
|
-- Check if it is already lit (avoid double loop)
|
||||||
if hardtorch.em_loop[user:get_player_name()] then
|
-- Verifica se ja esta acesa (evitar loop duplo)
|
||||||
|
if hardtorch.in_loop[user:get_player_name()] then
|
||||||
return
|
return
|
||||||
end
|
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 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
|
then
|
||||||
return hardtorch.acender_tocha(itemstack, user)
|
return hardtorch.turnon_torch(itemstack, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check if turn on with lighter
|
||||||
|
-- Verifica se acendeu com acendedor
|
||||||
for tool,def in pairs(hardtorch.registered_lighters) do
|
for tool,def in pairs(hardtorch.registered_lighters) do
|
||||||
if hardtorch.find_item(user, tool) then
|
if hardtorch.find_item(user, tool) then
|
||||||
local list, i, item = hardtorch.find_and_get_item(user, tool)
|
local list, i, item = hardtorch.find_and_get_item(user, tool)
|
||||||
item:add_wear(def.wear_by_use)
|
item:add_wear(def.wear_by_use)
|
||||||
user:get_inventory():set_stack(list, i, item)
|
user:get_inventory():set_stack(list, i, item)
|
||||||
return hardtorch.acender_tocha(itemstack, user)
|
return hardtorch.turnon_torch(itemstack, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(user:get_player_name(), S("Without heat source or lighter"))
|
minetest.chat_send_player(user:get_player_name(), S("Without heat source or lighter"))
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
return hardtorch.acender_tocha(itemstack, user)
|
return hardtorch.turnon_torch(itemstack, user)
|
||||||
end,
|
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)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
|
-- Check for avoidable nodes
|
||||||
-- Verifica nodes evitaveis
|
-- 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
|
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
|
if n == nn then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -194,8 +233,9 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
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 under = pointed_thing.under
|
||||||
local node = minetest.get_node(under)
|
local node = minetest.get_node(under)
|
||||||
local defnode = minetest.registered_nodes[node.name]
|
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,
|
return defnode.on_rightclick(under, node, placer, itemstack,
|
||||||
pointed_thing) or itemstack
|
pointed_thing) or itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Checks for any impediments in place
|
||||||
-- Verifica se tem algum impedimento no local
|
-- Verifica se tem algum impedimento no local
|
||||||
if hardtorch.check_torch_area(pointed_thing.above) == false then
|
if hardtorch.check_torch_area(pointed_thing.above) == false then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Verificar se é um node
|
-- Check if is a node
|
||||||
|
-- Verificar se é um nó
|
||||||
if not minetest.registered_nodes[torchname] then
|
if not minetest.registered_nodes[torchname] then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set node according to side placement
|
||||||
-- Definir node de acordo com posicionamento
|
-- Definir node de acordo com posicionamento
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
|
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
|
||||||
|
@ -225,8 +268,9 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
else
|
else
|
||||||
itemstack:set_name(def.nodes.node_wall or def.nodes.node)
|
itemstack:set_name(def.nodes.node_wall or def.nodes.node)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Coloca node apagado
|
-- Set turned off torch
|
||||||
|
-- Coloca nó de tocha apagado
|
||||||
if hardtorch.registered_torchs[torchname].nodes_off then
|
if hardtorch.registered_torchs[torchname].nodes_off then
|
||||||
itemstack:set_name(hardtorch.registered_torchs[torchname].nodes_off.node)
|
itemstack:set_name(hardtorch.registered_torchs[torchname].nodes_off.node)
|
||||||
end
|
end
|
||||||
|
@ -234,7 +278,7 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove item do inventario
|
-- Remove item from inventory
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -242,14 +286,16 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Versao acessa
|
-- Lit version
|
||||||
|
-- Versao acesa
|
||||||
minetest.override_item(torchname.."_on", {
|
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)
|
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
|
local under = pointed_thing.under
|
||||||
if under then
|
if under then
|
||||||
local node = minetest.get_node(under)
|
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
|
if itemstack:get_name() ~= torchname.."_on" then return end
|
||||||
|
|
||||||
-- Remover luz
|
-- Remove light from player
|
||||||
hardtorch.som_apagar(user:getpos(), torchname)
|
hardtorch.turnoff_sound(user:getpos(), torchname)
|
||||||
hardtorch.apagar_node_luz(user:get_player_name())
|
hardtorch.apagar_node_luz(user:get_player_name())
|
||||||
hardtorch.remover_luz_hud(user)
|
hardtorch.remove_light_hud(user)
|
||||||
itemstack:set_name(torchname)
|
itemstack:set_name(torchname)
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -276,23 +322,25 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
on_drop = function(itemstack, dropper, pos)
|
on_drop = function(itemstack, dropper, pos)
|
||||||
if itemstack:get_name() ~= torchname.."_on" then return end
|
if itemstack:get_name() ~= torchname.."_on" then return end
|
||||||
|
|
||||||
-- Remover luz
|
-- Remove light from player
|
||||||
hardtorch.apagar_node_luz(dropper:get_player_name())
|
hardtorch.apagar_node_luz(dropper:get_player_name())
|
||||||
hardtorch.remover_luz_hud(dropper)
|
hardtorch.remove_light_hud(dropper)
|
||||||
itemstack:set_name(torchname)
|
itemstack:set_name(torchname)
|
||||||
minetest.item_drop(itemstack, dropper, pos)
|
minetest.item_drop(itemstack, dropper, pos)
|
||||||
itemstack:clear()
|
itemstack:clear()
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
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)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
|
-- Check for avoidable nodes
|
||||||
-- Verifica nodes evitaveis
|
-- 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
|
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
|
if n == nn then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -305,7 +353,8 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
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 under = pointed_thing.under
|
||||||
local node = minetest.get_node(under)
|
local node = minetest.get_node(under)
|
||||||
local defnode = minetest.registered_nodes[node.name]
|
local defnode = minetest.registered_nodes[node.name]
|
||||||
|
@ -315,24 +364,27 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
pointed_thing) or itemstack
|
pointed_thing) or itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Verifica se ja iniciou loop
|
-- Check if it is already lit (avoid double loop)
|
||||||
local loop = hardtorch.em_loop[placer:get_player_name()]
|
-- Verifica se ja esta acesa (evitar loop duplo)
|
||||||
|
local loop = hardtorch.in_loop[placer:get_player_name()]
|
||||||
if not loop then
|
if not loop then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Verifica se tem combustivel
|
-- Check fuel
|
||||||
|
-- Verifica combustivel
|
||||||
local inv = placer:get_inventory()
|
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
|
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
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Checks for any impediments in place
|
||||||
-- Verifica se tem algum impedimento no local
|
-- Verifica se tem algum impedimento no local
|
||||||
if hardtorch.check_torch_area(pointed_thing.above) == false then
|
if hardtorch.check_torch_area(pointed_thing.above) == false then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set node according to side placement
|
||||||
-- Definir node de acordo com posicionamento
|
-- Definir node de acordo com posicionamento
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, 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
|
if not itemstack then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Repassa desgaste de combustivel
|
-- Set fuel wear to node
|
||||||
|
-- Repassa desgaste de combustivel ao nó
|
||||||
local fuelname, fuelwear
|
local fuelname, fuelwear
|
||||||
fuelname = loop.fuel.name
|
fuelname = loop.fuel.name
|
||||||
fuelwear = inv:get_stack(loop.fuel.list, loop.fuel.i):get_wear()
|
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)
|
meta:set_int("hardtorch_wear", fuelwear)
|
||||||
minetest.get_node_timer(pointed_thing.above):start(hardtorch.get_node_timeout(pointed_thing.above))
|
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()
|
itemstack:take_item()
|
||||||
|
|
||||||
-- Remover luz
|
-- Remove light from player
|
||||||
hardtorch.apagar_node_luz(placer:get_player_name())
|
hardtorch.apagar_node_luz(placer:get_player_name())
|
||||||
hardtorch.remover_luz_hud(placer)
|
hardtorch.remove_light_hud(placer)
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
@ -377,12 +430,14 @@ hardtorch.register_tool = function(torchname, def)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Turn off wielded torch when player disconnect
|
||||||
-- Apaga tocha da mão quando o jogador desconecta
|
-- Apaga tocha da mão quando o jogador desconecta
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if hardtorch.em_loop[name] then
|
if hardtorch.in_loop[name] then
|
||||||
hardtorch.apagar_tocha(player, hardtorch.em_loop[name].torchname)
|
hardtorch.turnoff_torch(player, hardtorch.in_loop[name].torchname)
|
||||||
hardtorch.em_loop[name] = nil
|
hardtorch.in_loop[name] = nil
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
109
torchs/lamp.lua
|
@ -1,29 +1,27 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
Oil Lamp
|
||||||
Registro de Lamparina
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
-- Used for localization
|
-- Used for localization
|
||||||
|
|
||||||
local S = minetest.get_translator("hardtorch")
|
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 lamp_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_lamp_light_source") or 13)
|
||||||
|
|
||||||
local tile_anim = {
|
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}
|
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Tool nodebox
|
||||||
-- Node-ferramenta
|
|
||||||
local tool_nodebox = {
|
local tool_nodebox = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
|
@ -37,44 +35,43 @@ local tool_nodebox = {
|
||||||
{0.25, -0.375, -0.375, 0.375, 0.5, -0.25}, -- NodeBox4
|
{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.375, -0.25, 0.5, -0.25}, -- NodeBox5
|
||||||
{-0.375, -0.375, 0.25, -0.25, 0.5, 0.375}, -- NodeBox6
|
{-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.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
|
{-0.25, -0.375+1, -0.25, 0.25, -0.25+1, 0.25}, -- NodeBox2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Node nodebox
|
||||||
-- Nodeboxes
|
|
||||||
local node_nodebox = {
|
local node_nodebox = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.1875, -0.4375, 0.0625, 0.1875, -0.25, 0.1875}, -- Tanque1
|
{-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}, -- Tanque2
|
{-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}, -- Tanque3
|
{-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}, -- Tanque4
|
{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}, -- Haste1
|
{-0.1875, -0.5, 0.125, -0.125, 0, 0.1875}, -- Stem 1
|
||||||
{0.125, -0.5, 0.125, 0.1875, 0, 0.1875}, -- Haste2
|
{0.125, -0.5, 0.125, 0.1875, 0, 0.1875}, -- Stem 2
|
||||||
{-0.1875, -0.5, -0.1875, -0.125, 0, -0.125}, -- Haste3
|
{-0.1875, -0.5, -0.1875, -0.125, 0, -0.125}, -- Stem 3
|
||||||
{0.125, -0.5, -0.1875, 0.1875, 0, -0.125}, -- Haste4
|
{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.5, -0.25, 0.25, -0.4375, 0.25}, -- Base
|
||||||
{-0.25, 0, -0.25, 0.25, 0.0625, 0.25}, -- Tampa
|
{-0.25, 0, -0.25, 0.25, 0.0625, 0.25}, -- Cover
|
||||||
{-0.125, 0.0625, -0.125, 0.125, 0.125, 0.125}, -- Tampa2
|
{-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}, -- Vela
|
{-0.0625, -0.25, -0.0625, 0.0625, 0, 0.0625}, -- Torch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Register node
|
||||||
-- Register node de lamparina
|
-- Register node de lamparina
|
||||||
local def_lamp = minetest.serialize({
|
local def_lamp = minetest.serialize({
|
||||||
description = S("Oil Lamp"),
|
description = S("Oil Lamp"),
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
tiles = {
|
tiles = {
|
||||||
"hardtorch_lamp_wield_cima.png",
|
"hardtorch_lamp_wield_top.png",
|
||||||
"hardtorch_lamp_wield_baixo.png",
|
"hardtorch_lamp_wield_bottom.png",
|
||||||
"hardtorch_lamp_wield_lado.png",
|
"hardtorch_lamp_wield_side.png",
|
||||||
"hardtorch_lamp_wield_lado.png",
|
"hardtorch_lamp_wield_side.png",
|
||||||
"hardtorch_lamp_wield_lado.png",
|
"hardtorch_lamp_wield_side.png",
|
||||||
"hardtorch_lamp_wield_lado.png"
|
"hardtorch_lamp_wield_side.png"
|
||||||
},
|
},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -89,7 +86,8 @@ local def_lamp = minetest.serialize({
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Node-ferramenta
|
-- Oil Lamp node
|
||||||
|
-- Nó da lamparina
|
||||||
minetest.register_node("hardtorch:lamp", minetest.deserialize(def_lamp))
|
minetest.register_node("hardtorch:lamp", minetest.deserialize(def_lamp))
|
||||||
minetest.override_item("hardtorch:lamp", {
|
minetest.override_item("hardtorch:lamp", {
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
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
|
if not minetest.item_place(itemstack, placer, pointed_thing) then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove item do inventario
|
-- Remove from inventory
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
|
||||||
return itemstack
|
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.register_node("hardtorch:lamp_on", minetest.deserialize(def_lamp))
|
||||||
minetest.override_item("hardtorch:lamp_on", {
|
minetest.override_item("hardtorch:lamp_on", {
|
||||||
description = S("Oil Lamp Lit"),
|
description = S("Oil Lamp Lit"),
|
||||||
|
@ -121,12 +120,12 @@ minetest.override_item("hardtorch:lamp_on", {
|
||||||
paramtype = nil,
|
paramtype = nil,
|
||||||
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
|
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
|
||||||
tiles = {
|
tiles = {
|
||||||
"hardtorch_lamp_wield_cima.png",
|
"hardtorch_lamp_wield_top.png",
|
||||||
"hardtorch_lamp_wield_baixo.png",
|
"hardtorch_lamp_wield_bottom.png",
|
||||||
"hardtorch_lamp_wield_lado_on.png",
|
"hardtorch_lamp_wield_side_on.png",
|
||||||
"hardtorch_lamp_wield_lado_on.png",
|
"hardtorch_lamp_wield_side_on.png",
|
||||||
"hardtorch_lamp_wield_lado_on.png",
|
"hardtorch_lamp_wield_side_on.png",
|
||||||
"hardtorch_lamp_wield_lado_on.png"
|
"hardtorch_lamp_wield_side_on.png"
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -136,24 +135,24 @@ minetest.override_item("hardtorch:lamp_node", {
|
||||||
drop = "hardtorch:lamp",
|
drop = "hardtorch:lamp",
|
||||||
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
|
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
|
||||||
tiles = {
|
tiles = {
|
||||||
"hardtorch_lamp_cima.png",
|
"hardtorch_lamp_top.png",
|
||||||
"hardtorch_lamp_baixo.png",
|
"hardtorch_lamp_bottom.png",
|
||||||
"hardtorch_lamp_lado.png",
|
"hardtorch_lamp_side.png",
|
||||||
"hardtorch_lamp_lado.png",
|
"hardtorch_lamp_side.png",
|
||||||
"hardtorch_lamp_lado.png",
|
"hardtorch_lamp_side.png",
|
||||||
"hardtorch_lamp_lado.png"
|
"hardtorch_lamp_side.png"
|
||||||
},
|
},
|
||||||
node_box = node_nodebox,
|
node_box = node_nodebox,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Node ativo
|
-- Active node
|
||||||
minetest.register_node("hardtorch:lamp_node_active", minetest.deserialize(def_lamp))
|
minetest.register_node("hardtorch:lamp_node_active", minetest.deserialize(def_lamp))
|
||||||
minetest.override_item("hardtorch:lamp_node_active", {
|
minetest.override_item("hardtorch:lamp_node_active", {
|
||||||
light_source = lamp_light_source,
|
light_source = lamp_light_source,
|
||||||
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
|
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, not_in_creative_inventory = 1},
|
||||||
tiles = {
|
tiles = {
|
||||||
"hardtorch_lamp_cima.png",
|
"hardtorch_lamp_top.png",
|
||||||
"hardtorch_lamp_baixo.png",
|
"hardtorch_lamp_bottom.png",
|
||||||
tile_anim,
|
tile_anim,
|
||||||
tile_anim,
|
tile_anim,
|
||||||
tile_anim,
|
tile_anim,
|
||||||
|
@ -163,6 +162,7 @@ minetest.override_item("hardtorch:lamp_node_active", {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
-- Register Oil Lamp
|
||||||
-- Registrar Lamparina
|
-- Registrar Lamparina
|
||||||
hardtorch.register_torch("hardtorch:lamp", {
|
hardtorch.register_torch("hardtorch:lamp", {
|
||||||
light_source = lamp_light_source,
|
light_source = lamp_light_source,
|
||||||
|
@ -175,12 +175,13 @@ hardtorch.register_torch("hardtorch:lamp", {
|
||||||
sounds = {
|
sounds = {
|
||||||
turn_on = {name="hardtorch_click_oil_lamp", gain=0.2},
|
turn_on = {name="hardtorch_click_oil_lamp", gain=0.2},
|
||||||
turn_off = {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"},
|
fuel = {"hardtorch:oil"},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
-- Oil Lamp recipe
|
||||||
-- Receita da Lamparina
|
-- Receita da Lamparina
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'hardtorch:lamp',
|
output = 'hardtorch:lamp',
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
Default Torchs
|
||||||
Registro de Tochas padrao
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
-- Used for localization
|
-- Used for localization
|
||||||
|
|
||||||
local S = minetest.get_translator("hardtorch")
|
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)
|
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))
|
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
|
if torch_nights <= 0 then torch_nights = 0.1 end
|
||||||
|
|
||||||
|
|
||||||
|
-- Default torch adjustment
|
||||||
-- Ajuste na tocha padrão
|
-- Ajuste na tocha padrão
|
||||||
do
|
do
|
||||||
minetest.override_item("default:torch", {
|
minetest.override_item("default:torch", {
|
||||||
|
-- Change image to player know that need to light it
|
||||||
-- Muda imagem para jogador saber que tem que acendela
|
-- Muda imagem para jogador saber que tem que acendela
|
||||||
inventory_image = "hardtorch_torch_tool_off.png",
|
inventory_image = "hardtorch_torch_tool_off.png",
|
||||||
wield_image = "hardtorch_torch_tool_off.png",
|
wield_image = "hardtorch_torch_tool_off.png",
|
||||||
|
@ -33,12 +36,14 @@ do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Register the lit torch like fuel
|
||||||
-- Registra a tocha acessa como um combustivel
|
-- Registra a tocha acessa como um combustivel
|
||||||
hardtorch.register_fuel("hardtorch:torch_on", {
|
hardtorch.register_fuel("hardtorch:torch_on", {
|
||||||
turns = torch_nights,
|
turns = torch_nights,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Registrar ferramentas
|
-- Register tool
|
||||||
|
-- Registrar ferramenta
|
||||||
minetest.register_tool("hardtorch:torch", {
|
minetest.register_tool("hardtorch:torch", {
|
||||||
description = S("Torch (used)"),
|
description = S("Torch (used)"),
|
||||||
inventory_image = "hardtorch_torch_tool_off.png",
|
inventory_image = "hardtorch_torch_tool_off.png",
|
||||||
|
@ -46,14 +51,15 @@ minetest.register_tool("hardtorch:torch", {
|
||||||
groups = {not_in_creative_inventory = 1},
|
groups = {not_in_creative_inventory = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Lit version tool
|
||||||
-- Versao acessa da ferramenta
|
-- Versao acessa da ferramenta
|
||||||
minetest.register_tool("hardtorch:torch_on", {
|
minetest.register_tool("hardtorch:torch_on", {
|
||||||
inventory_image = "hardtorch_torch_tool_on.png",
|
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},
|
groups = {not_in_creative_inventory = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Registrar tocha
|
-- Register torch
|
||||||
hardtorch.register_torch("hardtorch:torch", {
|
hardtorch.register_torch("hardtorch:torch", {
|
||||||
light_source = minetest.registered_nodes["default:torch"].light_source,
|
light_source = minetest.registered_nodes["default:torch"].light_source,
|
||||||
fuel = {"hardtorch:torch_on"},
|
fuel = {"hardtorch:torch_on"},
|
||||||
|
@ -63,8 +69,8 @@ hardtorch.register_torch("hardtorch:torch", {
|
||||||
node_wall = "default:torch_wall"
|
node_wall = "default:torch_wall"
|
||||||
},
|
},
|
||||||
sounds = {
|
sounds = {
|
||||||
turn_on = {name="hardtorch_acendendo_tocha", gain=0.2},
|
turn_on = {name="hardtorch_turnon_torch", gain=0.2},
|
||||||
turn_off = {name="hardtorch_apagando_tocha", gain=0.2},
|
turn_off = {name="hardtorch_turnoff_torch", gain=0.2},
|
||||||
water_turn_off = {name="hardtorch_apagando_tocha", gain=0.2},
|
water_turn_off = {name="hardtorch_turnoff_torch", gain=0.2},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,32 +1,31 @@
|
||||||
--[[
|
--[[
|
||||||
Mod HardTorch para Minetest
|
Mod HardTorch for Minetest
|
||||||
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
Recebeste uma cópia da GNU Lesser General
|
You should have received a copy of the GNU General Public License
|
||||||
Public License junto com esse software,
|
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||||
se não, veja em <http://www.gnu.org/licenses/>.
|
|
||||||
|
Candle from xdecor mod
|
||||||
Registro de Vela (candle) do mod xdecor
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
if minetest.registered_nodes["xdecor:candle"] == nil then return end
|
if minetest.registered_nodes["xdecor:candle"] == nil then return end
|
||||||
|
|
||||||
-- Used for localization
|
|
||||||
|
|
||||||
|
-- Used for localization
|
||||||
local S = minetest.get_translator("hardtorch")
|
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)
|
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))
|
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
|
if candle_nights <= 0 then candle_nights = 0.8 end
|
||||||
|
|
||||||
|
|
||||||
-- Ajuste na vela (candle) do mod xdecor
|
-- Candle adjustment
|
||||||
do
|
do
|
||||||
minetest.override_item("xdecor:candle", {
|
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",
|
inventory_image = "xdecor_candle_wield.png",
|
||||||
wield_image = "xdecor_candle_wield.png",
|
wield_image = "xdecor_candle_wield.png",
|
||||||
light_source = candle_light_source
|
light_source = candle_light_source
|
||||||
|
@ -34,12 +33,12 @@ do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Registra a tocha acessa como um combustivel
|
-- Register the lit torch like fuel
|
||||||
hardtorch.register_fuel("hardtorch:xdecor_candle_on", {
|
hardtorch.register_fuel("hardtorch:xdecor_candle_on", {
|
||||||
turns = candle_nights,
|
turns = candle_nights,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Registrar ferramentas
|
-- Register tool
|
||||||
minetest.register_tool("hardtorch:xdecor_candle", {
|
minetest.register_tool("hardtorch:xdecor_candle", {
|
||||||
description = S("Candle (used)"),
|
description = S("Candle (used)"),
|
||||||
inventory_image = "xdecor_candle_wield.png",
|
inventory_image = "xdecor_candle_wield.png",
|
||||||
|
@ -47,14 +46,14 @@ minetest.register_tool("hardtorch:xdecor_candle", {
|
||||||
groups = {not_in_creative_inventory = 1},
|
groups = {not_in_creative_inventory = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Versao acessa da ferramenta
|
-- Lit version tool
|
||||||
minetest.register_tool("hardtorch:xdecor_candle_on", {
|
minetest.register_tool("hardtorch:xdecor_candle_on", {
|
||||||
inventory_image = "xdecor_candle_inv.png",
|
inventory_image = "xdecor_candle_inv.png",
|
||||||
wield_image = "xdecor_candle_inv.png",
|
wield_image = "xdecor_candle_inv.png",
|
||||||
groups = {not_in_creative_inventory = 1},
|
groups = {not_in_creative_inventory = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Registrar tocha
|
-- Register Candle
|
||||||
hardtorch.register_torch("hardtorch:xdecor_candle", {
|
hardtorch.register_torch("hardtorch:xdecor_candle", {
|
||||||
light_source = minetest.registered_nodes["xdecor:candle"].light_source,
|
light_source = minetest.registered_nodes["xdecor:candle"].light_source,
|
||||||
fuel = {"hardtorch:xdecor_candle_on"},
|
fuel = {"hardtorch:xdecor_candle_on"},
|
||||||
|
|