From c2afc82754311c83c868063689e88554963562f2 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 19 Aug 2020 20:39:05 +0200 Subject: [PATCH] Disable some demanding particles by default Fire smoke, lava droplets --- mods/CORE/mcl_particles/init.lua | 23 +++++++++++++++++++---- mods/ITEMS/mcl_core/nodes_liquid.lua | 2 +- mods/ITEMS/mcl_fire/init.lua | 2 +- mods/ITEMS/mcl_furnaces/init.lua | 2 +- mods/ITEMS/mcl_torches/init.lua | 8 ++++---- settingtypes.txt | 7 +++++-- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/mods/CORE/mcl_particles/init.lua b/mods/CORE/mcl_particles/init.lua index d3b4d02a..049ec36d 100644 --- a/mods/CORE/mcl_particles/init.lua +++ b/mods/CORE/mcl_particles/init.lua @@ -6,15 +6,30 @@ mcl_particles = {} local particle_nodes = {} -- 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. -- * pos: Node positon. MUST use integer values! -- * 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. -- Returns particlespawner ID on succcess and nil on failure -function mcl_particles.add_node_particlespawner(pos, particlespawner_definition) - if not node_particles_allowed then +function mcl_particles.add_node_particlespawner(pos, particlespawner_definition, level) + if allowed_level == 0 or levels[level] > allowed_level then return end local poshash = minetest.hash_node_position(pos) @@ -37,7 +52,7 @@ end -- 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 + if allowed_level == 0 then return false end local poshash = minetest.hash_node_position(pos) diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index 68213e0c..57b3e588 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -227,7 +227,7 @@ local emit_lava_particle = function(pos) }) end -if minetest.settings:get_bool("mcl_node_particles", true) then +if minetest.settings:get("mcl_node_particles") == "full" then minetest.register_abm({ label = "Lava particles", nodenames = {"group:lava_source"}, diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index a25aecdb..81b963ea 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -24,7 +24,7 @@ local spawn_smoke = function(pos) aspect_h = 8, length = 2.05, }, - }) + }, "high") end -- diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index 19304961..ce58b8c9 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -379,7 +379,7 @@ local function spawn_flames(pos, param2) maxsize = 0.8, texture = "mcl_particles_flame.png", glow = LIGHT_ACTIVE_FURNACE, - }) + }, "low") end local on_rotate, after_rotate_active diff --git a/mods/ITEMS/mcl_torches/init.lua b/mods/ITEMS/mcl_torches/init.lua index 90751d49..17930835 100644 --- a/mods/ITEMS/mcl_torches/init.lua +++ b/mods/ITEMS/mcl_torches/init.lua @@ -16,7 +16,7 @@ local spawn_flames_floor = function(pos) maxsize = 2, texture = "mcl_particles_flame.png", glow = LIGHT_TORCH, - }) + }, "low") -- Smoke mcl_particles.add_node_particlespawner(pos, { amount = 0.5, @@ -36,7 +36,7 @@ local spawn_flames_floor = function(pos) aspect_h = 8, length = 2.05, }, - }) + }, "medium") end local spawn_flames_wall = function(pos, param2) @@ -71,7 +71,7 @@ local spawn_flames_wall = function(pos, param2) maxsize = 2, texture = "mcl_particles_flame.png", glow = LIGHT_TORCH, - }) + }, "low") -- Smoke mcl_particles.add_node_particlespawner(pos, { amount = 0.5, @@ -91,7 +91,7 @@ local spawn_flames_wall = function(pos, param2) aspect_h = 8, length = 2.05, }, - }) + }, "medium") end local remove_flames = function(pos) diff --git a/settingtypes.txt b/settingtypes.txt index 1e2129ce..eed0a6b0 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -27,8 +27,11 @@ mcl_doTileDrops (Blocks have drops) bool true # If enabled, TNT explosions destroy blocks. mcl_tnt_griefing (TNT destroys blocks) bool true -# If enabled, some blocks will emit decorative particles like flames. -mcl_node_particles (Block particles) bool true +# Some blocks will emit decorative particles like flames. This setting +# 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] # If enabled, players respawn at the bed they last lay on instead of normal