forked from VoxeLibre/VoxeLibre
Add flame particles to torches and furnaces
This commit is contained in:
parent
b14eb70241
commit
2a1273b7e3
|
@ -0,0 +1,35 @@
|
||||||
|
local particle_nodes = {}
|
||||||
|
|
||||||
|
mcl_particles = {}
|
||||||
|
|
||||||
|
-- Add a particlespawner that is assigned to a given node position.
|
||||||
|
-- * pos: Node positon. MUST use rounded values!
|
||||||
|
-- * particlespawner_definition: definition for minetest.add_particlespawner
|
||||||
|
-- NOTE: All particlespawners are automatically removed on shutdown.
|
||||||
|
-- Returns particlespawner ID on succcess and nil on failure
|
||||||
|
function mcl_particles.add_node_particlespawner(pos, particlespawner_definition)
|
||||||
|
local poshash = minetest.hash_node_position(pos)
|
||||||
|
if not poshash then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local id = minetest.add_particlespawner(particlespawner_definition)
|
||||||
|
if id == -1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
particle_nodes[poshash] = id
|
||||||
|
return id
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Deleted a particlespawner that is assigned to a node position, if one exists.
|
||||||
|
-- Otherwise, this does nothing.
|
||||||
|
-- pos: Node positon. MUST use rounded values!
|
||||||
|
-- Returns true if particlespawner could be removed and false if none existed
|
||||||
|
function mcl_particles.delete_node_particlespawner(pos)
|
||||||
|
local poshash = minetest.hash_node_position(pos)
|
||||||
|
local id = particle_nodes[poshash]
|
||||||
|
if id then
|
||||||
|
minetest.delete_particlespawner(id)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
Binary file not shown.
After Width: | Height: | Size: 145 B |
|
@ -4,5 +4,6 @@ mcl_core
|
||||||
mcl_sounds
|
mcl_sounds
|
||||||
mcl_craftguide
|
mcl_craftguide
|
||||||
mcl_achievements
|
mcl_achievements
|
||||||
|
mcl_particles
|
||||||
doc?
|
doc?
|
||||||
screwdriver?
|
screwdriver?
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
local S = minetest.get_translator("mcl_furnaces")
|
local S = minetest.get_translator("mcl_furnaces")
|
||||||
|
|
||||||
|
local LIGHT_ACTIVE_FURNACE = 13
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Formspecs
|
-- Formspecs
|
||||||
--
|
--
|
||||||
|
@ -346,9 +348,48 @@ local function furnace_node_timer(pos, elapsed)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
local on_rotate
|
local function spawn_flames(pos, param2)
|
||||||
|
local minrelpos, maxrelpos
|
||||||
|
local dir = minetest.facedir_to_dir(param2)
|
||||||
|
if dir.x > 0 then
|
||||||
|
minrelpos = { x = -0.6, y = -0.05, z = -0.25 }
|
||||||
|
maxrelpos = { x = -0.55, y = -0.45, z = 0.25 }
|
||||||
|
elseif dir.x < 0 then
|
||||||
|
minrelpos = { x = 0.55, y = -0.05, z = -0.25 }
|
||||||
|
maxrelpos = { x = 0.6, y = -0.45, z = 0.25 }
|
||||||
|
elseif dir.z > 0 then
|
||||||
|
minrelpos = { x = -0.25, y = -0.05, z = -0.6 }
|
||||||
|
maxrelpos = { x = 0.25, y = -0.45, z = -0.55 }
|
||||||
|
elseif dir.z < 0 then
|
||||||
|
minrelpos = { x = -0.25, y = -0.05, z = 0.55 }
|
||||||
|
maxrelpos = { x = 0.25, y = -0.45, z = 0.6 }
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
mcl_particles.add_node_particlespawner(pos, {
|
||||||
|
amount = 4,
|
||||||
|
time = 0,
|
||||||
|
minpos = vector.add(pos, minrelpos),
|
||||||
|
maxpos = vector.add(pos, maxrelpos),
|
||||||
|
minvel = { x = -0.01, y = 0, z = -0.01 },
|
||||||
|
maxvel = { x = 0.01, y = 0.1, z = 0.01 },
|
||||||
|
minexptime = 0.3,
|
||||||
|
maxexptime = 0.6,
|
||||||
|
minsize = 0.4,
|
||||||
|
maxsize = 0.8,
|
||||||
|
texture = "mcl_particles_flame.png",
|
||||||
|
glow = LIGHT_ACTIVE_FURNACE,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_rotate, after_rotate_active
|
||||||
if minetest.get_modpath("screwdriver") then
|
if minetest.get_modpath("screwdriver") then
|
||||||
on_rotate = screwdriver.rotate_simple
|
on_rotate = screwdriver.rotate_simple
|
||||||
|
after_rotate_active = function(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
mcl_particles.delete_node_particlespawner(pos)
|
||||||
|
spawn_flames(pos, node.param2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_furnaces:furnace", {
|
minetest.register_node("mcl_furnaces:furnace", {
|
||||||
|
@ -431,7 +472,7 @@ minetest.register_node("mcl_furnaces:furnace_active", {
|
||||||
},
|
},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 13,
|
light_source = LIGHT_ACTIVE_FURNACE,
|
||||||
drop = "mcl_furnaces:furnace",
|
drop = "mcl_furnaces:furnace",
|
||||||
groups = {pickaxey=1, container=4, deco_block=1, not_in_creative_inventory=1, material_stone=1},
|
groups = {pickaxey=1, container=4, deco_block=1, not_in_creative_inventory=1, material_stone=1},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
@ -453,6 +494,13 @@ minetest.register_node("mcl_furnaces:furnace_active", {
|
||||||
meta:from_table(meta2:to_table())
|
meta:from_table(meta2:to_table())
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
spawn_flames(pos, node.param2)
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
mcl_particles.delete_node_particlespawner(pos)
|
||||||
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||||
|
@ -462,6 +510,7 @@ minetest.register_node("mcl_furnaces:furnace_active", {
|
||||||
_mcl_blast_resistance = 3.5,
|
_mcl_blast_resistance = 3.5,
|
||||||
_mcl_hardness = 3.5,
|
_mcl_hardness = 3.5,
|
||||||
on_rotate = on_rotate,
|
on_rotate = on_rotate,
|
||||||
|
after_rotate = after_rotate_active,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -478,6 +527,16 @@ if minetest.get_modpath("doc") then
|
||||||
doc.add_entry_alias("nodes", "mcl_furnaces:furnace", "nodes", "mcl_furnaces:furnace_active")
|
doc.add_entry_alias("nodes", "mcl_furnaces:furnace", "nodes", "mcl_furnaces:furnace_active")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "Active furnace flame particles",
|
||||||
|
name = "mcl_furnaces:flames",
|
||||||
|
nodenames = {"mcl_furnaces:furnace_active"},
|
||||||
|
run_at_every_load = true,
|
||||||
|
action = function(pos, node)
|
||||||
|
spawn_flames(pos, node.param2)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Legacy
|
-- Legacy
|
||||||
minetest.register_lbm({
|
minetest.register_lbm({
|
||||||
label = "Update furnace formspecs (0.60.0",
|
label = "Update furnace formspecs (0.60.0",
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
mcl_core
|
mcl_core
|
||||||
mcl_sounds
|
mcl_sounds
|
||||||
|
mcl_particles
|
||||||
doc?
|
doc?
|
||||||
|
|
|
@ -1,4 +1,60 @@
|
||||||
local S = minetest.get_translator("mcl_torches")
|
local S = minetest.get_translator("mcl_torches")
|
||||||
|
local LIGHT_TORCH = minetest.LIGHT_MAX
|
||||||
|
|
||||||
|
local spawn_flames_floor = function(pos)
|
||||||
|
return mcl_particles.add_node_particlespawner(pos, {
|
||||||
|
amount = 8,
|
||||||
|
time = 0,
|
||||||
|
minpos = vector.add(pos, { x = -0.1, y = 0.05, z = -0.1 }),
|
||||||
|
maxpos = vector.add(pos, { x = 0.1, y = 0.15, z = 0.1 }),
|
||||||
|
minvel = { x = -0.01, y = 0, z = -0.01 },
|
||||||
|
maxvel = { x = 0.01, y = 0.1, z = 0.01 },
|
||||||
|
minexptime = 0.3,
|
||||||
|
maxexptime = 0.6,
|
||||||
|
minsize = 0.7,
|
||||||
|
maxsize = 2,
|
||||||
|
texture = "mcl_particles_flame.png",
|
||||||
|
glow = LIGHT_TORCH,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local spawn_flames_wall = function(pos, param2)
|
||||||
|
local minrelpos, maxrelpos
|
||||||
|
local dir = minetest.wallmounted_to_dir(param2)
|
||||||
|
if dir.x < 0 then
|
||||||
|
minrelpos = { x = -0.38, y = 0.04, z = -0.1 }
|
||||||
|
maxrelpos = { x = -0.2, y = 0.14, z = 0.1 }
|
||||||
|
elseif dir.x > 0 then
|
||||||
|
minrelpos = { x = 0.2, y = 0.04, z = -0.1 }
|
||||||
|
maxrelpos = { x = 0.38, y = 0.14, z = 0.1 }
|
||||||
|
elseif dir.z < 0 then
|
||||||
|
minrelpos = { x = -0.1, y = 0.04, z = -0.38 }
|
||||||
|
maxrelpos = { x = 0.1, y = 0.14, z = -0.2 }
|
||||||
|
elseif dir.z > 0 then
|
||||||
|
minrelpos = { x = -0.1, y = 0.04, z = 0.2 }
|
||||||
|
maxrelpos = { x = 0.1, y = 0.14, z = 0.38 }
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return mcl_particles.add_node_particlespawner(pos, {
|
||||||
|
amount = 8,
|
||||||
|
time = 0,
|
||||||
|
minpos = vector.add(pos, minrelpos),
|
||||||
|
maxpos = vector.add(pos, maxrelpos),
|
||||||
|
minvel = { x = -0.01, y = 0, z = -0.01 },
|
||||||
|
maxvel = { x = 0.01, y = 0.1, z = 0.01 },
|
||||||
|
minexptime = 0.3,
|
||||||
|
maxexptime = 0.6,
|
||||||
|
minsize = 0.7,
|
||||||
|
maxsize = 2,
|
||||||
|
texture = "mcl_particles_flame.png",
|
||||||
|
glow = LIGHT_TORCH,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local remove_flames = function(pos)
|
||||||
|
mcl_particles.delete_node_particlespawner(pos)
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- 3d torch part
|
-- 3d torch part
|
||||||
|
@ -43,7 +99,7 @@ end
|
||||||
|
|
||||||
mcl_torches = {}
|
mcl_torches = {}
|
||||||
|
|
||||||
mcl_torches.register_torch = function(substring, description, doc_items_longdesc, doc_items_usagehelp, icon, mesh_floor, mesh_wall, tiles, light, groups, sounds, moredef)
|
mcl_torches.register_torch = function(substring, description, doc_items_longdesc, doc_items_usagehelp, icon, mesh_floor, mesh_wall, tiles, light, groups, sounds, moredef, moredef_floor, moredef_wall)
|
||||||
local itemstring = minetest.get_current_modname()..":"..substring
|
local itemstring = minetest.get_current_modname()..":"..substring
|
||||||
local itemstring_wall = minetest.get_current_modname()..":"..substring.."_wall"
|
local itemstring_wall = minetest.get_current_modname()..":"..substring.."_wall"
|
||||||
|
|
||||||
|
@ -138,6 +194,11 @@ mcl_torches.register_torch = function(substring, description, doc_items_longdesc
|
||||||
floordef[k] = v
|
floordef[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if moredef_floor ~= nil then
|
||||||
|
for k,v in pairs(moredef_floor) do
|
||||||
|
floordef[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
minetest.register_node(itemstring, floordef)
|
minetest.register_node(itemstring, floordef)
|
||||||
|
|
||||||
local groups_wall = table.copy(groups)
|
local groups_wall = table.copy(groups)
|
||||||
|
@ -169,6 +230,11 @@ mcl_torches.register_torch = function(substring, description, doc_items_longdesc
|
||||||
walldef[k] = v
|
walldef[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if moredef_wall ~= nil then
|
||||||
|
for k,v in pairs(moredef_wall) do
|
||||||
|
walldef[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
minetest.register_node(itemstring_wall, walldef)
|
minetest.register_node(itemstring_wall, walldef)
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,11 +255,20 @@ mcl_torches.register_torch("torch",
|
||||||
name = "default_torch_on_floor_animated.png",
|
name = "default_torch_on_floor_animated.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}
|
||||||
}},
|
}},
|
||||||
minetest.LIGHT_MAX,
|
LIGHT_TORCH,
|
||||||
{dig_immediate=3, torch=1, deco_block=1},
|
{dig_immediate=3, torch=1, deco_block=1},
|
||||||
mcl_sounds.node_sound_wood_defaults(),
|
mcl_sounds.node_sound_wood_defaults(),
|
||||||
{_doc_items_hidden = false})
|
{_doc_items_hidden = false,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
remove_flames(pos)
|
||||||
|
end},
|
||||||
|
{on_construct = function(pos)
|
||||||
|
spawn_flames_floor(pos)
|
||||||
|
end},
|
||||||
|
{on_construct = function(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
spawn_flames_wall(pos, node.param2)
|
||||||
|
end})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_torches:torch 4",
|
output = "mcl_torches:torch 4",
|
||||||
|
@ -203,3 +278,17 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "Torch flame particles",
|
||||||
|
name = "mcl_torches:flames",
|
||||||
|
nodenames = {"mcl_torches:torch", "mcl_torches:torch_wall"},
|
||||||
|
run_at_every_load = true,
|
||||||
|
action = function(pos, node)
|
||||||
|
if node.name == "mcl_torches:torch" then
|
||||||
|
spawn_flames_floor(pos)
|
||||||
|
elseif node.name == "mcl_torches:torch_wall" then
|
||||||
|
spawn_flames_wall(pos, node.param2)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue