Rail Logistics Dispatcher

by Viidi

Adds a dispatcher (building) to automate railway logistics based on offers and requests. The mod is optimized for multi-delivery deliveries, has an intuitive interface and is published under a free license.

Content
1 year, 3 months ago
1.1
1.49K
Trains

b Crash when request station tries to request cargo

1 year, 4 months ago

Not sure why this station is different when a lot of others work, but I'm getting a crash when trying to set up a request station. Steps to reproduce:

  1. Open the dispatcher next to the character
  2. Click on Compressed Hydrogen request (the white fluid icon)
  3. Click on m2 preset.
  4. Click Apply.

Within a few seconds, game crashes with:

The mod Rail Logistics Dispatcher (0.0.15) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RailLogisticsDispatcher::on_nth_tick(2)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
    [C]: in function '__index'
    __RailLogisticsDispatcher__/script/SurClass.lua:358: in function '_tryToMakeDelivery'
    __RailLogisticsDispatcher__/script/SurClass.lua:246: in function <__RailLogisticsDispatcher__/script/SurClass.lua:194>
    (...tail calls...)
    __RailLogisticsDispatcher__/script/SurClass.lua:108: in function <__RailLogisticsDispatcher__/script/SurClass.lua:97>

Save file: http://cdn.modo.lv/temp/dispatch_bug.zip

1 year, 4 months ago
(updated 1 year, 4 months ago)

For now I worked around it by modifying the priority lookup code so that it removes any invalid stops from the request list:

if otherRequest then
    local reqPriority = requester.disp.priority
    local invalid
    for i, reqStop in pairs(otherRequest) do
        local priority = reqStop.disp.priority
        if math.abs(reqPriority - priority) > 0.000001 and priority > reqPriority then
            if reqStop.stopEntity.valid then
                hasMorePriority = reqStop
            else
                invalid = i
            end
            break
        end
    end
    if (invalid) then
        log("Removing request with invalid stop entity: " .. invalid)
        self.request[invalid] = nil
    end
end
1 year, 4 months ago

This is strange. There should be no invalid stations. Apparently somewhere I do not read them. I'll study the problem.

1 year, 4 months ago

And there is. I have corrected.

Thanks a lot!

1 year, 4 months ago

Unfortunately it looks like the error is still there:

The mod Rail Logistics Dispatcher (0.0.16) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event RailLogisticsDispatcher::on_nth_tick(2)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
    [C]: in function '__index'
    __RailLogisticsDispatcher__/script/SurClass.lua:364: in function '_tryToMakeDelivery'
    __RailLogisticsDispatcher__/script/SurClass.lua:246: in function <__RailLogisticsDispatcher__/script/SurClass.lua:194>
    (...tail calls...)
    __RailLogisticsDispatcher__/script/SurClass.lua:108: in function <__RailLogisticsDispatcher__/script/SurClass.lua:97>

Save file: https://cdn.modo.lv/temp/dispatch_bug_16.zip , just wait around for a few seconds and the crash happens.

1 year, 4 months ago

Thank you. I'll take a look at your save. Perhaps you need to do some kind of migration.

New response