Combat Robots Overhaul

by Wannie

Overhaul of Factorio's Combat Robots behaviour to make them more useful by automatically attacking enemies.

Tweaks
3 months ago
1.1 - 2.1
12.1K
Combat

b Crash when entering a specific map area – invalid LuaEntity in destroyer group update

14 days ago

Hello,

I am using Combat Robot Overhaul version 2.1.31 together with Krastorio 2 on Factorio 2.0.77, without Space Age.

When I enter a specific area of the map with the player character, the game terminates and reports an unrecoverable error caused by Combat Robot Overhaul. The problem appears to be connected to a destroyer combat robot group located in, or activated by entering, that area.

Steps to reproduce:

  1. Load the affected save.
  2. Move the player character into the affected map area.
  3. As soon as the area is entered, Combat Robot Overhaul produces the error and the game terminates.

Expected behavior:

The combat robot group should update normally and the game should continue running.

Actual behavior:

During the periodic destroyer group update, Combat Robot Overhaul attempts to access a LuaEntity that is no longer valid, causing the game to terminate.

Full error message:

Error while running event CombatRobotsOverhaul::on_nth_tick(60)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
[C]: in function '__index'
CombatRobotsOverhaul/scripts/basegroup.lua:101: in function 'move_to_target'
CombatRobotsOverhaul/scripts/destroyergroup.lua:48: in function 'update'
CombatRobotsOverhaul/control.lua:302: in function <CombatRobotsOverhaul/control.lua:295>

Possible cause:

It appears that move_to_target in scripts/basegroup.lua, around line 101, accesses a combat robot, target, or another stored LuaEntity reference after that entity has been destroyed, removed, or otherwise invalidated. A validity check such as entity and entity.valid may be missing before the entity is accessed.

Entering the map area may only trigger the update of the affected destroyer group; the underlying issue seems to be an invalid entity reference stored by that group.

I can provide my complete mod list if required.

13 days ago

It appears that the target entity is not valid which sometimes can happen. (No idea why yet). It appears that the move_to_target only checks the entity but not if the entity is valid. So this will be fixed with the next version. Meanwhile, you can get rid of the invalid entity data by using the comand
/combatrobotoverhaul-clean-invalid.

New response