Added a config option 'ta_apiary_abm_enabled' to control if the ABMs are enabled or not

This commit is contained in:
Lesya-cpp 2023-08-23 03:55:14 +07:00
parent 851e6c1759
commit 32de288068
3 changed files with 53 additions and 44 deletions

View File

@ -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

View File

@ -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

2
settingtypes.txt Normal file
View File

@ -0,0 +1,2 @@
# Disables ABMs (to potentially increase performance)
ta_apiary_abm_enabled(Enable Apiary ABMs) bool true