Consolidate ABMs
authorparamat <mat.gregory@virginmedia.com>
Sat, 13 Feb 2016 08:33:58 +0000 (08:33 +0000)
committerparamat <mat.gregory@virginmedia.com>
Sun, 14 Feb 2016 05:22:20 +0000 (05:22 +0000)
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

mods/default/functions.lua
mods/farming/api.lua
mods/fire/init.lua
mods/flowers/init.lua
mods/stairs/init.lua
mods/tnt/init.lua

index 0137d9126737b08cf6306bc12449aa7e3d22d7fd..3afaec880cb4511c8ed55b0640017c052d57aa6e 100644 (file)
@@ -88,37 +88,24 @@ end
 -- Lavacooling
 --
 
-default.cool_lava_source = function(pos)
-       minetest.set_node(pos, {name = "default:obsidian"})
-       minetest.sound_play("default_cool_lava",
-               {pos = pos, max_hear_distance = 16, gain = 0.25})
-end
-
-default.cool_lava_flowing = function(pos)
-       minetest.set_node(pos, {name = "default:stone"})
+default.cool_lava = function(pos, node)
+       if node.name == "default:lava_source" then
+               minetest.set_node(pos, {name = "default:obsidian"})
+       else -- Lava flowing
+               minetest.set_node(pos, {name = "default:stone"})
+       end
        minetest.sound_play("default_cool_lava",
                {pos = pos, max_hear_distance = 16, gain = 0.25})
 end
 
 minetest.register_abm({
-       nodenames = {"default:lava_flowing"},
-       neighbors = {"group:water"},
-       interval = 1,
-       chance = 2,
-       catch_up = false,
-       action = function(...)
-               default.cool_lava_flowing(...)
-       end,
-})
-
-minetest.register_abm({
-       nodenames = {"default:lava_source"},
+       nodenames = {"default:lava_source", "default:lava_flowing"},
        neighbors = {"group:water"},
        interval = 1,
-       chance = 2,
+       chance = 1,
        catch_up = false,
        action = function(...)
-               default.cool_lava_source(...)
+               default.cool_lava(...)
        end,
 })
 
@@ -177,8 +164,8 @@ end
 minetest.register_abm({
        nodenames = {"default:cactus"},
        neighbors = {"group:sand"},
-       interval = 50,
-       chance = 20,
+       interval = 12,
+       chance = 83,
        action = function(...)
                default.grow_cactus(...)
        end
@@ -186,9 +173,9 @@ minetest.register_abm({
 
 minetest.register_abm({
        nodenames = {"default:papyrus"},
-       neighbors = {"default:dirt", "default:dirt_with_grass", "default:sand"},
-       interval = 50,
-       chance = 20,
+       neighbors = {"default:dirt", "default:dirt_with_grass"},
+       interval = 14,
+       chance = 71,
        action = function(...)
                default.grow_papyrus(...)
        end
@@ -358,8 +345,9 @@ minetest.register_abm({
 
 minetest.register_abm({
        nodenames = {"default:dirt"},
-       interval = 2,
-       chance = 200,
+       neighbors = {"air"},
+       interval = 6,
+       chance = 67,
        catch_up = false,
        action = function(pos, node)
                local above = {x = pos.x, y = pos.y + 1, z = pos.z}
@@ -384,8 +372,8 @@ minetest.register_abm({
 
 minetest.register_abm({
        nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass"},
-       interval = 2,
-       chance = 20,
+       interval = 8,
+       chance = 50,
        catch_up = false,
        action = function(pos, node)
                local above = {x = pos.x, y = pos.y + 1, z = pos.z}
@@ -407,7 +395,7 @@ minetest.register_abm({
 minetest.register_abm({
        nodenames = {"default:cobble"},
        neighbors = {"group:water"},
-       interval = 17,
+       interval = 16,
        chance = 200,
        catch_up = false,
        action = function(pos, node)
index 7123cbc1b66c4e273ea01427d0fa2979025c76a9..a0c1992f2492291fcc88228b98e129be5accaa4a 100644 (file)
@@ -264,8 +264,8 @@ farming.register_plant = function(name, def)
        minetest.register_abm({
                nodenames = {"group:" .. pname, "group:seed"},
                neighbors = {"group:soil"},
-               interval = 90,
-               chance = 2,
+               interval = 9,
+               chance = 20,
                action = function(pos, node)
                        local plant_height = minetest.get_item_group(node.name, pname)
 
index fc55b8dd8570ac6adba69a7c6566afd6f8c3ff83..a556662802a4e737b9e6005a240025a6cf9bcbe7 100644 (file)
@@ -170,7 +170,7 @@ minetest.register_abm({
        nodenames = {"fire:basic_flame", "fire:permanent_flame"},
        neighbors = {"group:puts_out_fire"},
        interval = 3,
-       chance = 2,
+       chance = 1,
        catch_up = false,
        action = function(p0, node, _, _)
                minetest.remove_node(p0)
@@ -189,7 +189,7 @@ if minetest.setting_getbool("disable_fire") then
        minetest.register_abm({
                nodenames = {"fire:basic_flame"},
                interval = 7,
-               chance = 2,
+               chance = 1,
                catch_up = false,
                action = function(p0, node, _, _)
                        minetest.remove_node(p0)
index dd8e031d03c5f6b716ee4cb490249f3fe1ecde00..dd90f4c9f29e11443e7a65226c9d6612cd2ab4fc 100644 (file)
@@ -76,8 +76,8 @@ end
 minetest.register_abm({
        nodenames = {"group:flora"},
        neighbors = {"default:dirt_with_grass", "default:desert_sand"},
-       interval = 50,
-       chance = 25,
+       interval = 13,
+       chance = 96,
        action = function(pos, node)
                pos.y = pos.y - 1
                local under = minetest.get_node(pos)
index ea2933b6c24523ac33c88fc1b538b12f61e601ff..7688d9050d27f6d68e83f763ef3b93bc357fa616 100644 (file)
@@ -233,7 +233,7 @@ end
 if replace then
        minetest.register_abm({
                nodenames = {"group:slabs_replace"},
-               interval = 8,
+               interval = 16,
                chance = 1,
                action = function(pos, node)
                        node.name = minetest.registered_nodes[node.name].replace_name
index 6a459655c1f3a8d8d00f1da4316a86f3825d64f6..e10ac2fe1e948f70a24b9d83b2883fe0823b6054 100644 (file)
@@ -376,7 +376,7 @@ minetest.register_node("tnt:gunpowder_burning", {
 minetest.register_abm({
        nodenames = {"tnt:tnt", "tnt:gunpowder"},
        neighbors = {"fire:basic_flame", "default:lava_source", "default:lava_flowing"},
-       interval = 1,
+       interval = 4,
        chance = 1,
        action = burn,
 })