0
0
Fork 0

Disable some demanding particles by default

Fire smoke, lava droplets
This commit is contained in:
Wuzzy 2020-08-19 20:39:05 +02:00
parent c0aeb2f15f
commit c2afc82754
6 changed files with 31 additions and 13 deletions

View File

@ -6,15 +6,30 @@ mcl_particles = {}
local particle_nodes = {} 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("mcl_node_particles") or "medium"
local levels = {
high = 3,
medium = 2,
low = 1,
none = 0,
}
allowed_level = levels[node_particles_allowed]
if not allowed_level then
allowed_level = levels["medium"]
end
-- 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 integer values! -- * pos: Node positon. MUST use integer values!
-- * particlespawner_definition: definition for minetest.add_particlespawner -- * particlespawner_definition: definition for minetest.add_particlespawner
-- * level: detail level of particles. "high", "medium" or "low". High detail levels are for
-- CPU-demanding particles, like smoke of fire (which occurs frequently)
-- 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
function mcl_particles.add_node_particlespawner(pos, particlespawner_definition) function mcl_particles.add_node_particlespawner(pos, particlespawner_definition, level)
if not node_particles_allowed then if allowed_level == 0 or levels[level] > allowed_level then
return return
end end
local poshash = minetest.hash_node_position(pos) local poshash = minetest.hash_node_position(pos)
@ -37,7 +52,7 @@ end
-- pos: Node positon. MUST use integer values! -- pos: Node positon. MUST use integer values!
-- Returns true if particlespawner could be removed and false if not -- Returns true if particlespawner could be removed and false if not
function mcl_particles.delete_node_particlespawners(pos) function mcl_particles.delete_node_particlespawners(pos)
if not node_particles_allowed then if allowed_level == 0 then
return false return false
end end
local poshash = minetest.hash_node_position(pos) local poshash = minetest.hash_node_position(pos)

View File

@ -227,7 +227,7 @@ local emit_lava_particle = function(pos)
}) })
end end
if minetest.settings:get_bool("mcl_node_particles", true) then if minetest.settings:get("mcl_node_particles") == "full" then
minetest.register_abm({ minetest.register_abm({
label = "Lava particles", label = "Lava particles",
nodenames = {"group:lava_source"}, nodenames = {"group:lava_source"},

View File

@ -24,7 +24,7 @@ local spawn_smoke = function(pos)
aspect_h = 8, aspect_h = 8,
length = 2.05, length = 2.05,
}, },
}) }, "high")
end end
-- --

View File

@ -379,7 +379,7 @@ local function spawn_flames(pos, param2)
maxsize = 0.8, maxsize = 0.8,
texture = "mcl_particles_flame.png", texture = "mcl_particles_flame.png",
glow = LIGHT_ACTIVE_FURNACE, glow = LIGHT_ACTIVE_FURNACE,
}) }, "low")
end end
local on_rotate, after_rotate_active local on_rotate, after_rotate_active

View File

@ -16,7 +16,7 @@ local spawn_flames_floor = function(pos)
maxsize = 2, maxsize = 2,
texture = "mcl_particles_flame.png", texture = "mcl_particles_flame.png",
glow = LIGHT_TORCH, glow = LIGHT_TORCH,
}) }, "low")
-- Smoke -- Smoke
mcl_particles.add_node_particlespawner(pos, { mcl_particles.add_node_particlespawner(pos, {
amount = 0.5, amount = 0.5,
@ -36,7 +36,7 @@ local spawn_flames_floor = function(pos)
aspect_h = 8, aspect_h = 8,
length = 2.05, length = 2.05,
}, },
}) }, "medium")
end end
local spawn_flames_wall = function(pos, param2) local spawn_flames_wall = function(pos, param2)
@ -71,7 +71,7 @@ local spawn_flames_wall = function(pos, param2)
maxsize = 2, maxsize = 2,
texture = "mcl_particles_flame.png", texture = "mcl_particles_flame.png",
glow = LIGHT_TORCH, glow = LIGHT_TORCH,
}) }, "low")
-- Smoke -- Smoke
mcl_particles.add_node_particlespawner(pos, { mcl_particles.add_node_particlespawner(pos, {
amount = 0.5, amount = 0.5,
@ -91,7 +91,7 @@ local spawn_flames_wall = function(pos, param2)
aspect_h = 8, aspect_h = 8,
length = 2.05, length = 2.05,
}, },
}) }, "medium")
end end
local remove_flames = function(pos) local remove_flames = function(pos)

View File

@ -27,8 +27,11 @@ mcl_doTileDrops (Blocks have drops) bool true
# If enabled, TNT explosions destroy blocks. # If enabled, TNT explosions destroy blocks.
mcl_tnt_griefing (TNT destroys blocks) bool true mcl_tnt_griefing (TNT destroys blocks) bool true
# If enabled, some blocks will emit decorative particles like flames. # Some blocks will emit decorative particles like flames. This setting
mcl_node_particles (Block particles) bool true # specifies the detail level of particles, with higher levels being
# more CPU demanding.
# WARNING: The "high" level is really CPU intensive, use with care!
mcl_node_particles (Block particles detail level) enum medium high,medium,low,none
[Players] [Players]
# If enabled, players respawn at the bed they last lay on instead of normal # If enabled, players respawn at the bed they last lay on instead of normal