DanielKote / Foreman2

Visual planning tool for Factorio
Other
158 stars 14 forks source link

Seablock: foremanexport/instrument-control.lua:442: bad argument #1 of 2 to 'pairs' (table expected, got nil) #40

Closed Knofbath closed 1 year ago

Knofbath commented 1 year ago

Using SeaBlockMetaPack 1.1.3:

0.000 Error Util.cpp:83: The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_nth_tick(1)
__foremanexport__/instrument-control.lua:442: bad argument #1 of 2 to 'pairs' (table expected, got nil)
stack traceback:
    [C]: in function 'pairs'
    __foremanexport__/instrument-control.lua:442: in function 'ExportResources'
    __foremanexport__/instrument-control.lua:514: in function <__foremanexport__/instrument-control.lua:499>

Workaround by deleting function :442 in \foremanexport_1.0.0\instrument-control - nn.lua:

    for _, product in pairs(resource.mineable_properties.products) do
        tproduct = {}
        tproduct['name'] = product.name
        tproduct['type'] = product.type

        amount = (product.amount == nil) and ((product.amount_max + product.amount_min)/2) or product.amount
        amount = amount * ( (product.probability == nil) and 1 or product.probability)
        tproduct['amount'] = amount

        if product.type == 'fluid' and product.temperate ~= nil then
            tproduct['temperature'] = ProcessTemperature(product.temperature)
        end
        table.insert(tresource['products'], tproduct)
    end
mrozpara commented 1 year ago

it's better to add: if resource.mineable_properties.products ~= nil then ... end

gillett-hernandez commented 1 year ago

@Knofbath i have this issue fixed in my fork, along with a public release (v2.1.3). feel free to use that if you don't want to build the repo and patch it yourself.

Knofbath commented 1 year ago

@gillett-hernandez I had noticed your fix a while back, don't even need to build the repo, just pulling that .lua file out of it and replacing the existing one was good enough.

DanielKote commented 1 year ago

Will be fixed in latest version