mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Add smoke particles at torches
This commit is contained in:
parent
731f42ac88
commit
8a39474793
5 changed files with 68 additions and 17 deletions
|
@ -1,12 +1,15 @@
|
||||||
local particle_nodes = {}
|
|
||||||
|
|
||||||
mcl_particles = {}
|
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
|
-- Node particles can be disabled via setting
|
||||||
local node_particles_allowed = minetest.settings:get_bool("mcl_node_particles", true)
|
local node_particles_allowed = minetest.settings:get_bool("mcl_node_particles", true)
|
||||||
|
|
||||||
-- Add a particlespawner that is assigned to a given node position.
|
-- 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
|
-- * particlespawner_definition: definition for minetest.add_particlespawner
|
||||||
-- NOTE: All particlespawners are automatically removed on shutdown.
|
-- NOTE: All particlespawners are automatically removed on shutdown.
|
||||||
-- Returns particlespawner ID on succcess and nil on failure
|
-- 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
|
if id == -1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
particle_nodes[poshash] = id
|
if not particle_nodes[poshash] then
|
||||||
|
particle_nodes[poshash] = {}
|
||||||
|
end
|
||||||
|
table.insert(particle_nodes[poshash], id)
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Deleted a particlespawner that is assigned to a node position, if one exists.
|
-- Deletes all particlespawners that are assigned to a node position.
|
||||||
-- Otherwise, this does nothing.
|
-- If no particlespawners exist for this position, nothing happens.
|
||||||
-- pos: Node positon. MUST use rounded values!
|
-- pos: Node positon. MUST use integer values!
|
||||||
-- Returns true if particlespawner could be removed and false if none existed
|
-- Returns true if particlespawner could be removed and false if not
|
||||||
function mcl_particles.delete_node_particlespawner(pos)
|
function mcl_particles.delete_node_particlespawners(pos)
|
||||||
if not node_particles_allowed then
|
if not node_particles_allowed then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local poshash = minetest.hash_node_position(pos)
|
local poshash = minetest.hash_node_position(pos)
|
||||||
local id = particle_nodes[poshash]
|
local ids = particle_nodes[poshash]
|
||||||
if id then
|
if ids then
|
||||||
minetest.delete_particlespawner(id)
|
for i=1, #ids do
|
||||||
|
minetest.delete_particlespawner(ids[i])
|
||||||
|
end
|
||||||
|
particle_nodes[poshash] = nil
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 945 B After Width: | Height: | Size: 126 B |
BIN
mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png
Normal file
BIN
mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 216 B |
|
@ -387,7 +387,7 @@ if minetest.get_modpath("screwdriver") then
|
||||||
on_rotate = screwdriver.rotate_simple
|
on_rotate = screwdriver.rotate_simple
|
||||||
after_rotate_active = function(pos)
|
after_rotate_active = function(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
mcl_particles.delete_node_particlespawner(pos)
|
mcl_particles.delete_node_particlespawners(pos)
|
||||||
spawn_flames(pos, node.param2)
|
spawn_flames(pos, node.param2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -499,7 +499,7 @@ minetest.register_node("mcl_furnaces:furnace_active", {
|
||||||
spawn_flames(pos, node.param2)
|
spawn_flames(pos, node.param2)
|
||||||
end,
|
end,
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
mcl_particles.delete_node_particlespawner(pos)
|
mcl_particles.delete_node_particlespawners(pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||||
|
|
|
@ -2,7 +2,8 @@ local S = minetest.get_translator("mcl_torches")
|
||||||
local LIGHT_TORCH = minetest.LIGHT_MAX
|
local LIGHT_TORCH = minetest.LIGHT_MAX
|
||||||
|
|
||||||
local spawn_flames_floor = function(pos)
|
local spawn_flames_floor = function(pos)
|
||||||
return mcl_particles.add_node_particlespawner(pos, {
|
-- Flames
|
||||||
|
mcl_particles.add_node_particlespawner(pos, {
|
||||||
amount = 8,
|
amount = 8,
|
||||||
time = 0,
|
time = 0,
|
||||||
minpos = vector.add(pos, { x = -0.1, y = 0.05, z = -0.1 }),
|
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",
|
texture = "mcl_particles_flame.png",
|
||||||
glow = LIGHT_TORCH,
|
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
|
end
|
||||||
|
|
||||||
local spawn_flames_wall = function(pos, param2)
|
local spawn_flames_wall = function(pos, param2)
|
||||||
|
@ -36,7 +57,8 @@ local spawn_flames_wall = function(pos, param2)
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
return mcl_particles.add_node_particlespawner(pos, {
|
-- Flames
|
||||||
|
mcl_particles.add_node_particlespawner(pos, {
|
||||||
amount = 8,
|
amount = 8,
|
||||||
time = 0,
|
time = 0,
|
||||||
minpos = vector.add(pos, minrelpos),
|
minpos = vector.add(pos, minrelpos),
|
||||||
|
@ -50,10 +72,30 @@ local spawn_flames_wall = function(pos, param2)
|
||||||
texture = "mcl_particles_flame.png",
|
texture = "mcl_particles_flame.png",
|
||||||
glow = LIGHT_TORCH,
|
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
|
end
|
||||||
|
|
||||||
local remove_flames = function(pos)
|
local remove_flames = function(pos)
|
||||||
mcl_particles.delete_node_particlespawner(pos)
|
mcl_particles.delete_node_particlespawners(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in a new issue