Fix crash due to error attempt to get length of local 'woodResults' (a nil value)

This commit is contained in:
Simon Brodtmann 2025-02-04 23:11:27 +01:00
parent db4ef37a8f
commit 009fcf4d50
3 changed files with 8 additions and 3 deletions

View file

@ -81,12 +81,12 @@ for _, tree in pairs(data.raw.tree) do
end
local minable = tree.minable
local woodResults = minable.results and table.filter(minable.results, isWoodResult)
local isRegularTree = (minable.result == "wood" and minable.count == 4) or (#minable.results == 1 and #woodResults == 1 and woodResults[1].amount == 4)
local isRegularTree = (minable.result == "wood" and minable.count == 4) or (minable.results and #minable.results == 1 and #woodResults == 1 and woodResults[1].amount == 4)
if not isRegularTree then goto continue end
tree.minable.result = nil
tree.minable.count = nil
local woodResult = { type = "item", name = "wood", amount = nil, amount_min = 2, amount_max = 10 }
if #woodResults > 0 then
if minable.results and #woodResults > 0 then
table.assign(woodResults[1], woodResult)
else
minable.results = { woodResult }