1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-23 15:20:19 +01:00

Consolidate ABMs

Spread ABM intervals evenly across 1 to 16 seconds
16s ensures no nodes are missed when player walks past
Adjust chance values to compensate, for identical action rates
Combine lavacooling ABMs into one, return to chance = 1
Grass growth: add 'neighbors = "air"' to avoid
processing the thousands of underground dirt nodes
Grass death: Reduce action rate to that of grass growth
Fire: Use chance = 1 for flame extinguishing
and flame removal when mod is disabled
This commit is contained in:
paramat 2016-02-13 08:33:58 +00:00
parent 04f01bc57f
commit 7d2dfe4101
6 changed files with 28 additions and 40 deletions

View File

@ -88,37 +88,24 @@ end
-- Lavacooling -- Lavacooling
-- --
default.cool_lava_source = function(pos) default.cool_lava = function(pos, node)
if node.name == "default:lava_source" then
minetest.set_node(pos, {name = "default:obsidian"}) minetest.set_node(pos, {name = "default:obsidian"})
minetest.sound_play("default_cool_lava", else -- Lava flowing
{pos = pos, max_hear_distance = 16, gain = 0.25})
end
default.cool_lava_flowing = function(pos)
minetest.set_node(pos, {name = "default:stone"}) minetest.set_node(pos, {name = "default:stone"})
end
minetest.sound_play("default_cool_lava", minetest.sound_play("default_cool_lava",
{pos = pos, max_hear_distance = 16, gain = 0.25}) {pos = pos, max_hear_distance = 16, gain = 0.25})
end end
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:lava_flowing"}, nodenames = {"default:lava_source", "default:lava_flowing"},
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 1, interval = 1,
chance = 2, chance = 1,
catch_up = false, catch_up = false,
action = function(...) action = function(...)
default.cool_lava_flowing(...) default.cool_lava(...)
end,
})
minetest.register_abm({
nodenames = {"default:lava_source"},
neighbors = {"group:water"},
interval = 1,
chance = 2,
catch_up = false,
action = function(...)
default.cool_lava_source(...)
end, end,
}) })
@ -177,8 +164,8 @@ end
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:cactus"}, nodenames = {"default:cactus"},
neighbors = {"group:sand"}, neighbors = {"group:sand"},
interval = 50, interval = 12,
chance = 20, chance = 83,
action = function(...) action = function(...)
default.grow_cactus(...) default.grow_cactus(...)
end end
@ -186,9 +173,9 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:papyrus"}, nodenames = {"default:papyrus"},
neighbors = {"default:dirt", "default:dirt_with_grass", "default:sand"}, neighbors = {"default:dirt", "default:dirt_with_grass"},
interval = 50, interval = 14,
chance = 20, chance = 71,
action = function(...) action = function(...)
default.grow_papyrus(...) default.grow_papyrus(...)
end end
@ -358,8 +345,9 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:dirt"}, nodenames = {"default:dirt"},
interval = 2, neighbors = {"air"},
chance = 200, interval = 6,
chance = 67,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
local above = {x = pos.x, y = pos.y + 1, z = pos.z} local above = {x = pos.x, y = pos.y + 1, z = pos.z}
@ -384,8 +372,8 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass"}, nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass"},
interval = 2, interval = 8,
chance = 20, chance = 50,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
local above = {x = pos.x, y = pos.y + 1, z = pos.z} local above = {x = pos.x, y = pos.y + 1, z = pos.z}
@ -407,7 +395,7 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:cobble"}, nodenames = {"default:cobble"},
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 17, interval = 16,
chance = 200, chance = 200,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)

View File

@ -264,8 +264,8 @@ farming.register_plant = function(name, def)
minetest.register_abm({ minetest.register_abm({
nodenames = {"group:" .. pname, "group:seed"}, nodenames = {"group:" .. pname, "group:seed"},
neighbors = {"group:soil"}, neighbors = {"group:soil"},
interval = 90, interval = 9,
chance = 2, chance = 20,
action = function(pos, node) action = function(pos, node)
local plant_height = minetest.get_item_group(node.name, pname) local plant_height = minetest.get_item_group(node.name, pname)

View File

@ -170,7 +170,7 @@ minetest.register_abm({
nodenames = {"fire:basic_flame", "fire:permanent_flame"}, nodenames = {"fire:basic_flame", "fire:permanent_flame"},
neighbors = {"group:puts_out_fire"}, neighbors = {"group:puts_out_fire"},
interval = 3, interval = 3,
chance = 2, chance = 1,
catch_up = false, catch_up = false,
action = function(p0, node, _, _) action = function(p0, node, _, _)
minetest.remove_node(p0) minetest.remove_node(p0)
@ -189,7 +189,7 @@ if minetest.setting_getbool("disable_fire") then
minetest.register_abm({ minetest.register_abm({
nodenames = {"fire:basic_flame"}, nodenames = {"fire:basic_flame"},
interval = 7, interval = 7,
chance = 2, chance = 1,
catch_up = false, catch_up = false,
action = function(p0, node, _, _) action = function(p0, node, _, _)
minetest.remove_node(p0) minetest.remove_node(p0)

View File

@ -76,8 +76,8 @@ end
minetest.register_abm({ minetest.register_abm({
nodenames = {"group:flora"}, nodenames = {"group:flora"},
neighbors = {"default:dirt_with_grass", "default:desert_sand"}, neighbors = {"default:dirt_with_grass", "default:desert_sand"},
interval = 50, interval = 13,
chance = 25, chance = 96,
action = function(pos, node) action = function(pos, node)
pos.y = pos.y - 1 pos.y = pos.y - 1
local under = minetest.get_node(pos) local under = minetest.get_node(pos)

View File

@ -233,7 +233,7 @@ end
if replace then if replace then
minetest.register_abm({ minetest.register_abm({
nodenames = {"group:slabs_replace"}, nodenames = {"group:slabs_replace"},
interval = 8, interval = 16,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
node.name = minetest.registered_nodes[node.name].replace_name node.name = minetest.registered_nodes[node.name].replace_name

View File

@ -376,7 +376,7 @@ minetest.register_node("tnt:gunpowder_burning", {
minetest.register_abm({ minetest.register_abm({
nodenames = {"tnt:tnt", "tnt:gunpowder"}, nodenames = {"tnt:tnt", "tnt:gunpowder"},
neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"}, neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"},
interval = 1, interval = 4,
chance = 1, chance = 1,
action = burn, action = burn,
}) })