unlit torches can be relit with flint&steel or gunpowder, timer settings added
This commit is contained in:
parent
88e6924a2b
commit
2879a08bd0
3
2d.lua
3
2d.lua
@ -39,6 +39,7 @@ minetest.override_item("default:torch", {
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(480, 600))
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
})
|
||||
|
23
3d.lua
23
3d.lua
@ -47,7 +47,11 @@ minetest.register_node("real_torch:torch", {
|
||||
itemstack:set_name("real_torch:torch")
|
||||
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
on_ignite = function(pos, igniter)
|
||||
local nod = minetest.get_node(pos)
|
||||
minetest.set_node(pos, {name = "default:torch", param2 = nod.param2})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
@ -70,6 +74,10 @@ minetest.register_node("real_torch:torch_wall", {
|
||||
wall_side = {-1/2, -1/2, -1/8, -1/8, 1/8, 1/8},
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_ignite = function(pos, igniter)
|
||||
local nod = minetest.get_node(pos)
|
||||
minetest.set_node(pos, {name = "default:torch_wall", param2 = nod.param2})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
@ -92,6 +100,10 @@ minetest.register_node("real_torch:torch_ceiling", {
|
||||
wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8},
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_ignite = function(pos, igniter)
|
||||
local nod = minetest.get_node(pos)
|
||||
minetest.set_node(pos, {name = "default:torch_ceiling", param2 = nod.param2})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
@ -106,7 +118,8 @@ minetest.override_item("default:torch", {
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(480, 600))
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
})
|
||||
|
||||
@ -121,7 +134,8 @@ minetest.override_item("default:torch_wall", {
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(480, 600))
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
})
|
||||
|
||||
@ -136,6 +150,7 @@ minetest.override_item("default:torch_ceiling", {
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(480, 600))
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end,
|
||||
})
|
||||
|
@ -1 +1,2 @@
|
||||
default
|
||||
tnt?
|
||||
|
116
init.lua
116
init.lua
@ -1,6 +1,12 @@
|
||||
|
||||
-- Realistic Torch mod by TenPlus1
|
||||
|
||||
real_torch = {}
|
||||
|
||||
-- check for timer settings or use defaults
|
||||
real_torch.min_duration = tonumber(minetest.setting_get("torch_min_duration")) or 480
|
||||
real_torch.max_duration = tonumber(minetest.setting_get("torch_min_duration")) or 600
|
||||
|
||||
|
||||
-- check which torch(es) are available in minetest version
|
||||
if minetest.registered_nodes["default:torch_ceiling"] then
|
||||
@ -17,7 +23,8 @@ minetest.register_lbm({
|
||||
nodenames = {"default:torch", "default:torch_wall", "default:torch_ceiling"},
|
||||
action = function(pos)
|
||||
if not minetest.get_node_timer(pos):is_started() then
|
||||
minetest.get_node_timer(pos):start(math.random(480, 600))
|
||||
minetest.get_node_timer(pos):start(
|
||||
math.random(real_torch.min_duration, real_torch.max_duration))
|
||||
end
|
||||
end
|
||||
})
|
||||
@ -37,20 +44,23 @@ minetest.register_craftitem("real_torch:coal_powder", {
|
||||
|
||||
local pos = pointed_thing.under
|
||||
local nod = minetest.get_node(pos)
|
||||
local rep = false
|
||||
|
||||
if nod.name == "real_torch:torch" then
|
||||
|
||||
minetest.set_node(pos, {name = "default:torch", param2 = nod.param2})
|
||||
itemstack:take_item()
|
||||
nod.name = "default:torch"
|
||||
rep = true
|
||||
|
||||
elseif nod.name == "real_torch:torch_wall" then
|
||||
|
||||
minetest.set_node(pos, {name = "default:torch_wall", param2 = nod.param2})
|
||||
itemstack:take_item()
|
||||
nod.name = "default:torch_wall"
|
||||
rep = true
|
||||
|
||||
elseif nod.name == "real_torch:torch_ceiling" then
|
||||
nod.name = "default:torch_ceiling"
|
||||
rep = true
|
||||
end
|
||||
|
||||
minetest.set_node(pos, {name = "default:torch_ceiling", param2 = nod.param2})
|
||||
if rep then
|
||||
minetest.set_node(pos, {name = nod.name, param2 = nod.param2})
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
@ -86,6 +96,7 @@ minetest.register_craft({
|
||||
recipe = {"real_torch:torch", "real_torch:coal_powder"},
|
||||
})
|
||||
|
||||
|
||||
-- Make sure Ethereal mod isn't running as this Abm already exists there
|
||||
if not minetest.get_modpath("ethereal") then
|
||||
|
||||
@ -134,3 +145,92 @@ minetest.register_abm({
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- particle effects
|
||||
local function add_effects(pos, radius)
|
||||
|
||||
minetest.add_particle({
|
||||
pos = pos,
|
||||
velocity = vector.new(),
|
||||
acceleration = vector.new(),
|
||||
expirationtime = 0.4,
|
||||
size = radius * 10,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "tnt_boom.png",
|
||||
glow = 15,
|
||||
})
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 16,
|
||||
time = 0.5,
|
||||
minpos = vector.subtract(pos, radius / 2),
|
||||
maxpos = vector.add(pos, radius / 2),
|
||||
minvel = {x = -2, y = -2, z = -2},
|
||||
maxvel = {x = 2, y = 2, z = 2},
|
||||
minacc = vector.new(),
|
||||
maxacc = vector.new(),
|
||||
minexptime = 1,
|
||||
maxexptime = 2.5,
|
||||
minsize = radius * 3,
|
||||
maxsize = radius * 5,
|
||||
texture = "tnt_smoke.png",
|
||||
})
|
||||
|
||||
minetest.sound_play("tnt_explode", {pos = pos, gain = 0.1, max_hear_distance = 5})
|
||||
end
|
||||
|
||||
|
||||
-- override tnt:gunpowder to explode when used on torch,
|
||||
-- will also re-light torches and cause player damage when used on lit torch.
|
||||
if minetest.get_modpath("tnt") then
|
||||
|
||||
minetest.override_item("tnt:gunpowder", {
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
||||
if not pointed_thing or pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = pointed_thing.under
|
||||
local nod = minetest.get_node(pos)
|
||||
|
||||
local rep = false
|
||||
|
||||
if nod.name == "real_torch:torch" then
|
||||
nod.name = "default:torch"
|
||||
rep = true
|
||||
|
||||
elseif nod.name == "real_torch:torch_wall" then
|
||||
nod.name = "default:torch_wall"
|
||||
rep = true
|
||||
|
||||
elseif nod.name == "real_torch:torch_ceiling" then
|
||||
nod.name = "default:torch_ceiling"
|
||||
rep = true
|
||||
end
|
||||
|
||||
if rep then
|
||||
minetest.set_node(pos, {name = nod.name, param2 = nod.param2})
|
||||
add_effects(pos, 1)
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
|
||||
if nod.name == "default:torch"
|
||||
or nod.name == "default:torch_wall"
|
||||
or nod.name == "default:torch_ceiling" then
|
||||
|
||||
user:set_hp(user:get_hp() - 2)
|
||||
|
||||
add_effects(pos, 1)
|
||||
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
@ -1,10 +1,14 @@
|
||||
Real Torch by TenPlus1
|
||||
|
||||
This mod changes minetest torches so that they have a life of 8-10 minutes.
|
||||
This mod changes minetest torches so that they have a life of 8-10 minutes which
|
||||
is configurable using the torch_min_duration and torch_max_duration settings.
|
||||
|
||||
- coal lumps can be crafted into coal powder
|
||||
- 2x coal lumps can be crafted into 10x coal powder
|
||||
- coal powder and an unlit torch can be crafted into a lit torch again
|
||||
- punching an unlit torch with coal powder relights it
|
||||
- punching an unlit torch with flint & steel relights it
|
||||
- punching an unlit torch with gunpowder explodes and relights it
|
||||
- never punch a lit torch with gunpowder, ow!
|
||||
- water near torches make them drop as unlit torches
|
||||
- coal powder can also be used for fuel or crafted into black dye
|
||||
|
||||
@ -18,3 +22,4 @@ Changelog:
|
||||
- 0.4 - Changed my mind, now detects old 2D or new 3D torches and works accordingly
|
||||
- 0.5 - 2x coal lumps give 10x coal dust, also fixed check for ethereal mod
|
||||
- 0.6 - Burnout and extinguish sounds added by tacotexmex :)
|
||||
- 0.7 - Torches can be re-lit using flint & steel and gunpowder, settings added
|
||||
|
Loading…
x
Reference in New Issue
Block a user