diff --git a/mods/bg_tree/decompose.lua b/mods/bg_tree/decompose.lua index 66adf0c..55390b6 100644 --- a/mods/bg_tree/decompose.lua +++ b/mods/bg_tree/decompose.lua @@ -7,20 +7,31 @@ local vec = blockgame.vector local leaves = modname .. ":leaves" local leaves_decomposing = modname .. ":leaves_decomposing" --- END OF NODE NAMES + + +local decompose_scores = { + dirty = 50, + leaves_decomposing = 30, +} + +local start_decompose_cost = 4000 blockgame.register_increasing_abm({ id = modname .. ":begin_decompose", label = "decompose leaves", nodenames = {leaves}, neighbors = {"group:dirty", leaves_decomposing}, - interval = 20, + interval = 30, chance = 4, rate = function (pos, node, data) - return data.value + math.random(4, 6) + local score = blockgame.score_nearby_nodes(pos, 2, decompose_scores, function (gain, distance) + return math.floor(gain / (distance ^ 3)) + end) + + return data.value + score end, check = function (pos, node, data) - return data.value >= 80 + return data.value >= start_decompose_cost end, action = function (pos, node, data) -- NOTE: might wanna access the 4 from somewhere, instead of directly knowing it. @@ -30,11 +41,6 @@ blockgame.register_increasing_abm({ end, }) -local decompose_scores = { - dirty = 50, - leaves_decomposing = 30, -} - local decompose_cost = 30000 local average_leaves_per_dirt = 4 @@ -53,7 +59,6 @@ blockgame.register_increasing_abm({ end) score = score + bonus - return data.value + score end, check = function (pos, node, data)