Fixes param1 and param2 assignment

This commit is contained in:
AliasAlreadyTaken 2024-07-09 01:49:03 +02:00
parent 29f5961aa4
commit fcb767fd55

View File

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