diff --git a/bee_hive.lua b/bee_hive.lua index c55024b..fa511a5 100644 --- a/bee_hive.lua +++ b/bee_hive.lua @@ -317,53 +317,57 @@ minetest.register_craft({ }, }) -minetest.register_abm({ - label = "spawn bee particles", - nodenames = {"ta_apiary:bee_hive"}, - interval = 10, - chance = 1, +if ta_apiary.abm_enabled then - action = function(pos, node) - -- Bee particle - minetest.add_particle({ - pos = {x = pos.x, y = pos.y, z = pos.z}, - velocity = { - x = (math.random() - 0.5) * 5, - y = (math.random() - 0.5) * 5, - z = (math.random() - 0.5) * 5 - }, - acceleration = { - x = math.random() - 0.5, - y = math.random() - 0.5, - z = math.random() - 0.5 - }, - expirationtime = math.random(2.5), - size = math.random(3), - collisiondetection = true, - texture = "bees_particle_bee.png", - }) - minetest.sound_play("bees", { - pos = pos, gain = 0.6, max_hear_distance = 5}, true) - end -}) + minetest.register_abm({ + label = "spawn bee particles", + nodenames = {"ta_apiary:bee_hive"}, + interval = 10, + chance = 1, + + action = function(pos, node) + -- Bee particle + minetest.add_particle({ + pos = {x = pos.x, y = pos.y, z = pos.z}, + velocity = { + x = (math.random() - 0.5) * 5, + y = (math.random() - 0.5) * 5, + z = (math.random() - 0.5) * 5 + }, + acceleration = { + x = math.random() - 0.5, + y = math.random() - 0.5, + z = math.random() - 0.5 + }, + expirationtime = math.random(2.5), + size = math.random(3), + collisiondetection = true, + texture = "bees_particle_bee.png", + }) + minetest.sound_play("bees", { + pos = pos, gain = 0.6, max_hear_distance = 5}, true) + end + }) -- spawning bees around bee hive -minetest.register_abm({ - label = "spawn bees around bee hives", - nodenames = {"ta_apiary:bee_hive"}, - neighbors = {"group:flower", "group:leaves"}, - interval = 30, - chance = 4, + minetest.register_abm({ + label = "spawn bees around bee hives", + nodenames = {"ta_apiary:bee_hive"}, + neighbors = {"group:flower", "group:leaves"}, + interval = 30, + chance = 4, - action = function(pos) - local p = { - x = pos.x + math.random(-5, 5), - y = pos.y - math.random(0, 3), - z = pos.z + math.random(-5, 5) - } - if minetest.get_node(p).name == "air" then - minetest.add_node(p, {name="bees:bees"}) + action = function(pos) + local p = { + x = pos.x + math.random(-5, 5), + y = pos.y - math.random(0, 3), + z = pos.z + math.random(-5, 5) + } + if minetest.get_node(p).name == "air" then + minetest.add_node(p, {name="bees:bees"}) + end end - end -}) + }) + +end diff --git a/lib.lua b/lib.lua index e729851..b5c815b 100644 --- a/lib.lua +++ b/lib.lua @@ -15,6 +15,9 @@ local M = minetest.get_meta ta_apiary = {} +ta_apiary.abm_enabled = minetest.settings:get_bool("ta_apiary_abm_enabled") ~= false + + ta_apiary.S = minetest.get_translator("ta_apiary") ta_apiary.CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer or {} end diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..0ee8fcc --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +# Disables ABMs (to potentially increase performance) +ta_apiary_abm_enabled(Enable Apiary ABMs) bool true