Resource Map Label Marker Fork

by zinful

Creates resource map label markers when chunks get generated and charted. 2.1 fork of Resource Map Label Marker by Kizrak.

Utilities
3 months ago
2.1
419
Environment Mining

b Crash on_init/on_configuration_changed: "attempt to compare two nil values" in global_lib.lua line 52

13 days ago

Hello! I encountered a non-recoverable error when running this mod alongside a large list of other mods.

Error:
Error while running event resource-map-label-marker-fork::on_init()
resource-map-label-marker-fork/global_lib.lua:52: attempt to compare two nil values
stack traceback:
resource-map-label-marker-fork/global_lib.lua:52: in function <resource-map-label-marker-fork/global_lib.lua:51>
[C]: in function 'sort'
resource-map-label-marker-fork/global_lib.lua:55: in function 'calculateIconTypes'
resource-map-label-marker-fork/control.lua:453: in function <resource-map-label-marker-fork/control.lua:452>

Cause
The crash happens during M.calculateIconTypes() because some custom mods introduce mining products that do not explicitly define a .probability key. When table.sort attempts to compare them, it encounters nil and panics.

Suggested Fix
Adding a fallback value (like 1) inside the sorter function fixes the crash completely. In global_lib.lua, lines 51-55 can be updated to:

    local products = value.mineable_properties.products or {}
    local sorter = function(a, b)
        local prob_a = a.probability or 1
        local prob_b = b.probability or 1
        return prob_a < prob_b
    end

    table.sort(products, sorter)

Tested and working for me.

5 days ago

Ok, same error here

The mod Resource Map Label Marker Fork (1.0.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event resource-map-label-marker-fork::on_init()
resource-map-label-marker-fork/global_lib.lua:52: attempt to compare two nil values
stack traceback:
resource-map-label-marker-fork/global_lib.lua:52: in function <resource-map-label-marker-fork/global_lib.lua:51>
[C]: in function 'sort'
resource-map-label-marker-fork/global_lib.lua:55: in function 'calculateIconTypes'
resource-map-label-marker-fork/control.lua:453: in function <resource-map-label-marker-fork/control.lua:452>

New response