diff --git a/mods/CORE/mcl_particles/init.lua b/mods/CORE/mcl_particles/init.lua index 4a89d733ec..d3b4d02a57 100644 --- a/mods/CORE/mcl_particles/init.lua +++ b/mods/CORE/mcl_particles/init.lua @@ -1,12 +1,15 @@ -local particle_nodes = {} - mcl_particles = {} +-- Table of particlespawner IDs on a per-node hash basis +-- Keys: node position hashes +-- Values: Tables of particlespawner IDs (each node pos can have an arbitrary number of particlespawners) +local particle_nodes = {} + -- Node particles can be disabled via setting local node_particles_allowed = minetest.settings:get_bool("mcl_node_particles", true) -- Add a particlespawner that is assigned to a given node position. --- * pos: Node positon. MUST use rounded values! +-- * pos: Node positon. MUST use integer 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 @@ -22,22 +25,28 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition) if id == -1 then return end - particle_nodes[poshash] = id + if not particle_nodes[poshash] then + particle_nodes[poshash] = {} + end + table.insert(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) +-- Deletes all particlespawners that are assigned to a node position. +-- If no particlespawners exist for this position, nothing happens. +-- pos: Node positon. MUST use integer values! +-- Returns true if particlespawner could be removed and false if not +function mcl_particles.delete_node_particlespawners(pos) if not node_particles_allowed then return false end local poshash = minetest.hash_node_position(pos) - local id = particle_nodes[poshash] - if id then - minetest.delete_particlespawner(id) + local ids = particle_nodes[poshash] + if ids then + for i=1, #ids do + minetest.delete_particlespawner(ids[i]) + end + particle_nodes[poshash] = nil return true end return false diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_smoke.png b/mods/CORE/mcl_particles/textures/mcl_particles_smoke.png index 6551db5b55..709cecf161 100644 Binary files a/mods/CORE/mcl_particles/textures/mcl_particles_smoke.png and b/mods/CORE/mcl_particles/textures/mcl_particles_smoke.png differ diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png b/mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png new file mode 100644 index 0000000000..6c85a6feb9 Binary files /dev/null and b/mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png differ diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index b2d69ad1d8..19304961e4 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -387,7 +387,7 @@ if minetest.get_modpath("screwdriver") then on_rotate = screwdriver.rotate_simple after_rotate_active = function(pos) local node = minetest.get_node(pos) - mcl_particles.delete_node_particlespawner(pos) + mcl_particles.delete_node_particlespawners(pos) spawn_flames(pos, node.param2) end end @@ -499,7 +499,7 @@ minetest.register_node("mcl_furnaces:furnace_active", { spawn_flames(pos, node.param2) end, on_destruct = function(pos) - mcl_particles.delete_node_particlespawner(pos) + mcl_particles.delete_node_particlespawners(pos) end, allow_metadata_inventory_put = allow_metadata_inventory_put, diff --git a/mods/ITEMS/mcl_torches/init.lua b/mods/ITEMS/mcl_torches/init.lua index c9ec1370c0..90751d4957 100644 --- a/mods/ITEMS/mcl_torches/init.lua +++ b/mods/ITEMS/mcl_torches/init.lua @@ -2,7 +2,8 @@ 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, { + -- Flames + mcl_particles.add_node_particlespawner(pos, { amount = 8, time = 0, minpos = vector.add(pos, { x = -0.1, y = 0.05, z = -0.1 }), @@ -16,6 +17,26 @@ local spawn_flames_floor = function(pos) texture = "mcl_particles_flame.png", glow = LIGHT_TORCH, }) + -- Smoke + mcl_particles.add_node_particlespawner(pos, { + amount = 0.5, + time = 0, + minpos = vector.add(pos, { x = -1/16, y = 0.04, z = -1/16 }), + maxpos = vector.add(pos, { x = -1/16, y = 0.06, z = -1/16 }), + minvel = { x = 0, y = 0.5, z = 0 }, + maxvel = { x = 0, y = 0.6, z = 0 }, + minexptime = 2.0, + maxexptime = 2.0, + minsize = 1.5, + maxsize = 1.5, + texture = "mcl_particles_smoke_anim.png", + animation = { + type = "vertical_frames", + aspect_w = 8, + aspect_h = 8, + length = 2.05, + }, + }) end local spawn_flames_wall = function(pos, param2) @@ -36,7 +57,8 @@ local spawn_flames_wall = function(pos, param2) else return end - return mcl_particles.add_node_particlespawner(pos, { + -- Flames + mcl_particles.add_node_particlespawner(pos, { amount = 8, time = 0, minpos = vector.add(pos, minrelpos), @@ -50,10 +72,30 @@ local spawn_flames_wall = function(pos, param2) texture = "mcl_particles_flame.png", glow = LIGHT_TORCH, }) + -- Smoke + mcl_particles.add_node_particlespawner(pos, { + amount = 0.5, + time = 0, + minpos = vector.add(pos, minrelpos), + maxpos = vector.add(pos, maxrelpos), + minvel = { x = 0, y = 0.5, z = 0 }, + maxvel = { x = 0, y = 0.6, z = 0 }, + minexptime = 2.0, + maxexptime = 2.0, + minsize = 1.5, + maxsize = 1.5, + texture = "mcl_particles_smoke_anim.png", + animation = { + type = "vertical_frames", + aspect_w = 8, + aspect_h = 8, + length = 2.05, + }, + }) end local remove_flames = function(pos) - mcl_particles.delete_node_particlespawner(pos) + mcl_particles.delete_node_particlespawners(pos) end --