From b6ffd7fc97fd3f9d3d0602da280a869e3907366e Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sat, 16 Jan 2021 01:07:48 -0700 Subject: [PATCH] made the pit plasma abm much more selective to reduce cpu load --- df_underworld_items/dependencies.lua | 10 +++++++ df_underworld_items/glowing_pit_plasma.lua | 32 +++++++++++----------- df_underworld_items/init.lua | 1 + 3 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 df_underworld_items/dependencies.lua diff --git a/df_underworld_items/dependencies.lua b/df_underworld_items/dependencies.lua new file mode 100644 index 0000000..7208d1d --- /dev/null +++ b/df_underworld_items/dependencies.lua @@ -0,0 +1,10 @@ +df_underworld_items.abm_neighbors = {} + +-- common nodes that can be found next to pit plasma, triggering matter degradation +-- don't trigger on air, that's for sparkle generation +df_underworld_items.abm_neighbors.pit_plasma = {"group:stone", "df_underworld_items:glow_amethyst", "group:lava", "group:water"} + +-- This stuff should only be used during initialization +minetest.after(0, function() + df_underworld_items.node_name = nil +end) \ No newline at end of file diff --git a/df_underworld_items/glowing_pit_plasma.lua b/df_underworld_items/glowing_pit_plasma.lua index c211fc1..07d7618 100644 --- a/df_underworld_items/glowing_pit_plasma.lua +++ b/df_underworld_items/glowing_pit_plasma.lua @@ -127,6 +127,7 @@ if df_underworld_items.config.destructive_pit_plasma then minetest.register_abm({ label = "glowing pit matter degradation", nodenames = {"group:pit_plasma"}, + neighbors = df_underworld_items.abm_neighbors.pit_plasma, interval = 2, chance = 30, catch_up = false, @@ -157,19 +158,18 @@ if df_underworld_items.config.destructive_pit_plasma then end end, }) -else - minetest.register_abm({ - label = "glowing pit sparkle", - nodenames = {"group:pit_plasma"}, - neighbors = {"air"}, - interval = 2, - chance = 30, - catch_up = false, - action = function(pos) - local air_pos = minetest.find_node_near(pos, 1, "air") - if air_pos then - sparkle(air_pos) - end - end, - }) -end \ No newline at end of file +end +minetest.register_abm({ + label = "glowing pit sparkle", + nodenames = {"group:pit_plasma"}, + neighbors = {"air"}, + interval = 2, + chance = 30, + catch_up = false, + action = function(pos) + local air_pos = minetest.find_node_near(pos, 1, "air") + if air_pos then + sparkle(air_pos) + end + end, +}) diff --git a/df_underworld_items/init.lua b/df_underworld_items/init.lua index 29effbf..0f2dc15 100644 --- a/df_underworld_items/init.lua +++ b/df_underworld_items/init.lua @@ -5,6 +5,7 @@ df_underworld_items.S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) dofile(modpath.."/config.lua") +dofile(modpath.."/dependencies.lua") dofile(modpath.."/doc.lua") dofile(modpath.."/crystals_amethyst.lua")