hardtorch/torchs/xdecor_candle.lua

71 lines
2.0 KiB
Lua
Raw Normal View History

2019-09-05 09:04:34 -07:00
--[[
2019-12-02 09:12:11 -08:00
Mod HardTorch for Minetest
2019-09-05 09:04:34 -07:00
Copyright (C) 2019 BrunoMine (https://github.com/BrunoMine)
2019-12-02 09:12:11 -08:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>5.
Candle from xdecor mod
2019-09-05 09:04:34 -07:00
]]
if minetest.registered_nodes["xdecor:candle"] == nil then return end
2019-12-01 05:56:43 -08:00
2019-12-02 09:12:11 -08:00
-- Used for localization
2019-12-01 05:56:43 -08:00
local S = minetest.get_translator("hardtorch")
2019-12-02 09:12:11 -08:00
-- Candle light
2019-12-01 05:56:43 -08:00
local candle_light_source = hardtorch.check_light_number(minetest.settings:get("hardtorch_xdecor_candle_light_source") or 7)
2019-09-05 09:04:34 -07:00
2019-12-02 09:12:11 -08:00
-- Candle durability (in nights)
2019-12-01 05:56:43 -08:00
local candle_nights = math.abs(tonumber(minetest.settings:get("hardtorch_xdecor_candle_nights") or 0.8))
2019-09-05 09:04:34 -07:00
if candle_nights <= 0 then candle_nights = 0.8 end
2019-12-02 09:12:11 -08:00
-- Candle adjustment
2019-09-05 09:04:34 -07:00
do
minetest.override_item("xdecor:candle", {
2019-12-02 09:12:11 -08:00
-- Change image to player know that need to light it
2019-09-05 09:04:34 -07:00
inventory_image = "xdecor_candle_wield.png",
wield_image = "xdecor_candle_wield.png",
light_source = candle_light_source
})
end
2019-12-02 09:12:11 -08:00
-- Register the lit torch like fuel
2019-09-05 09:04:34 -07:00
hardtorch.register_fuel("hardtorch:xdecor_candle_on", {
turns = candle_nights,
})
2019-12-02 09:12:11 -08:00
-- Register tool
2019-09-05 09:04:34 -07:00
minetest.register_tool("hardtorch:xdecor_candle", {
2019-12-01 05:56:43 -08:00
description = S("Candle (used)"),
2019-09-05 09:04:34 -07:00
inventory_image = "xdecor_candle_wield.png",
wield_image = "xdecor_candle_wield.png",
groups = {not_in_creative_inventory = 1},
})
2019-12-02 09:12:11 -08:00
-- Lit version tool
2019-09-05 09:04:34 -07:00
minetest.register_tool("hardtorch:xdecor_candle_on", {
inventory_image = "xdecor_candle_inv.png",
wield_image = "xdecor_candle_inv.png",
groups = {not_in_creative_inventory = 1},
})
2019-12-02 09:12:11 -08:00
-- Register Candle
2019-09-05 09:04:34 -07:00
hardtorch.register_torch("hardtorch:xdecor_candle", {
light_source = minetest.registered_nodes["xdecor:candle"].light_source,
fuel = {"hardtorch:xdecor_candle_on"},
nodes = {
2019-12-01 05:56:43 -08:00
node = "xdecor:candle",
node_ceiling = "xdecor:candle",
2019-09-05 09:04:34 -07:00
node_wall = "xdecor:candle"
},
sounds = {
turn_on = {name="hardtorch_acendendo_tocha", gain=0.2},
turn_off = {name="hardtorch_apagando_tocha", gain=0.2},
water_turn_off = {name="hardtorch_apagando_tocha", gain=0.2},
},
})