Brave New World

by canidae

RTS-like scenario for Factorio. Player character is removed, all work must be done by bots

Scenarios
2 years ago
0.16 - 1.1
8.12K

g Non-recoverable Error

3 years ago

I get this error message when I try to change what's being produced in an assembler. Only workaround I know of is to deconstruct the assembler and place a new one.

The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_player_main_inventory_changed (ID 32)
LuaInventory doesn't contain key hasbar.
stack traceback:
...Data/Roaming/Factorio/temp/currently-playing/control.lua:102: in function 'dropItems'
...Data/Roaming/Factorio/temp/currently-playing/control.lua:88: in function <...Data/Roaming/Factorio/temp/currently-playing/control.lua:30>
stack traceback:
[C]: in function '__index'
...Data/Roaming/Factorio/temp/currently-playing/control.lua:102: in function 'dropItems'
...Data/Roaming/Factorio/temp/currently-playing/control.lua:88: in function <...Data/Roaming/Factorio/temp/currently-playing/control.lua:30>

3 years ago

Yep , me too same error.

Error while running event level::on_player_cursor_stack_changed (ID 29)
LuaInventory doesn't contain key hasbar.
stack traceback:
...Data/Roaming/Factorio/temp/currently-playing/control.lua:102: in function 'dropItems'
...Data/Roaming/Factorio/temp/currently-playing/control.lua:436: in function <...Data/Roaming/Factorio/temp/currently-playing/control.lua:426>
stack traceback:
[C]: in function '__index'
...Data/Roaming/Factorio/temp/currently-playing/control.lua:102: in function 'dropItems'
...Data/Roaming/Factorio/temp/currently-playing/control.lua:436: in function <...Data/Roaming/Factorio/temp/currently-playing/control.lua:426>

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

I have a fix for ya on this. I've reproduced failures in dropItems when stone is destroyed. It seems that putting a ghost roboport on tops of stone, or fighting and stone being destroyed, or running over stone in a tank can cause this to be called with no entity.
In the bottom of dropItems function add this one line - certainly no danger, and I assure you it will remove alot of random crashes, which tend to happen late game:

    if count > 0 then
        -- now we're forced to spill items
        entity = entity or global.forces[player.force.name].roboport
        if (entity.valid) then
            entity.surface.spill_item_stack(entity.position, {name = name, count = count}, false, entity.force, false)
        end
    end

The only addition to that code is checking entity.valid. The only consequence is your tanks may get some stone in them.

1 year, 3 months ago

That's interesting. So the problem is that the entity that's causing the spill doesn't have a surface at the time the spill occurs. That's good to know.

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

Slight revision of the code to handle a very odd corner case:

    if count > 0 then
        -- now we're forced to spill items
        entity = entity or global.forces[player.force.name].roboport
        if entity and entity.valid then                    
             if (entity.name ~= "entity-ghost") then
                 entity.surface.spill_item_stack(entity.position, {name = name, count = count}, false, entity.force, false)
            end
        end
    end
1 year, 3 months ago

no real differences there - sorry, I can't delete that second code post

New response