From fcb767fd550bf6bd4180a15bd1fe436351dcfc34 Mon Sep 17 00:00:00 2001 From: AliasAlreadyTaken Date: Tue, 9 Jul 2024 01:49:03 +0200 Subject: [PATCH] Fixes param1 and param2 assignment --- internal_nodefunctions.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal_nodefunctions.lua b/internal_nodefunctions.lua index 268919c..7cd36dd 100644 --- a/internal_nodefunctions.lua +++ b/internal_nodefunctions.lua @@ -24,10 +24,10 @@ function yl_api_nodestages.on_construct(pos) return on_construct(pos) end local function get_target_nodename(node, pos, next_stages) local sum = 0 - for _, stage_chance in pairs(next_stages) do sum = sum + stage_chance[2] end + for _, stage_chance in pairs(next_stages) do sum = sum + (stage_chance[2] or 1) end local dice = math.random(sum) for _, stage_chance in pairs(next_stages) do - dice = dice - stage_chance[2] + dice = dice - (stage_chance[2] or 1) if dice <= 0 then if (minetest.registered_nodes[stage_chance[1]] == nil) then minetest.log("warning", @@ -73,8 +73,8 @@ local function on_timer(pos, elapsed) target_nodename, next_stage = get_target_nodename(node, pos, stage.next_stages) target_nodeparams = { - param1 = next_stage.param1, - param2 = next_stage.param2 + param1 = next_stage[4] and next_stage[4].param1 or 0, + param2 = next_stage[4] and next_stage[4].param2 or 0 } if (target_nodename == yl_api_nodestages.error) then