Hi! Sorry for the delay …
I fixed the bug in 4.1.2
One of them. Turns out that the other variables also make problems, and it's with "rtf-tree-01-1" again. I'm not really familiar with the tree prototypes, but apparently there are different ways to define them and you didn't allow for all of them. See the wiki:
variations
Type: table of TreePrototypeVariation
Array. Can't be empty. Either this or pictures must exist.
So, it's not guaranteed that tree.variations will exist, it could also be tree.pictures (which is an array of sprites). Even if there are tree.variations, size, width, and height may be hidden within different layers.
I've inserted the following right before line 9 (where is_vertical is called):
if not (w and h) then
log(prototype.name .. ": w=" .. tostring(w) .. ", h=" .. tostring(h) .. "\ttrunk: " .. serpent.block(trunk))
end
If you run this, you'll see that the the tree causing the crash has its trunk variations defined as layers, so height and width are not set where you expect to find them and will be nil. Too bad, I thought I could steal your code for identifying lying trees! :-)
By the way, I just checked the BI code: We don't seem to look for layers, we look for properties at the top layer and provide hard-coded fallback values if these properties are nil, e.g.:
for var_id, variation in pairs(tree.variations) do
variation.trunk.scale = (variation.trunk.scale or 1) * i / TREE_LEVELS
…
end
and changed the code to progress only trees with autoplace specification (using {filter = 'autoplace'}
).
This shouldn't touch your trees anymore, i hope ;P
Mind if you could verify that it works?
I haven't tested too much yet (simplified the code some more, and still find syntax errors or variables that shouldn't be used anymore). But we explicitly set tree.autoplace = nil, so as far as I can see they should be ignored in the control stage.