Hi! Thanks for the mod. I'm getting a non-recoverable crash when Custom Color is used together with AAI Programmable Vehicles.
Versions:
- Factorio 2.0
- Custom Color 3.2.1
- AAI Programmable Vehicles 0.8.5
Error:
Error while running event CustomColor::on_player_driving_changed_state (ID 34)
CustomColor/libraries/functions/cars.lua:59: attempt to index field '?' (a nil value)
stack traceback:
CustomColor/libraries/functions/cars.lua:59: in function <CustomColor/libraries/functions/cars.lua:51>
stack traceback:
[C]: in function 'set_passenger'
aai-programmable-vehicles/control.lua:1064: in function 'unit_create_entity_from_entity'
aai-programmable-vehicles/control.lua:1326: in function 'unit_update_mode'
aai-programmable-vehicles/control.lua:3415: in function 'unit_tick'
How it happens:
When an AI vehicle changes mode (e.g. a player gets in or out of a vehicle set to "Auto"), AAI Programmable Vehicles destroys the vehicle and creates a new identical entity in its place, then moves the driver/passenger to it with set_driver / set_passenger. This raises on_player_driving_changed_state for an entity that Custom Color has never seen, so the lookup at cars.lua:59 returns nil and the mod crashes.
Suggested fix:
Add a nil/valid check before indexing the car's entry at cars.lua:59 (and initialise the entry if it doesn't exist yet), so that vehicles created or swapped by other mods are handled gracefully.
For now I've had to disable Custom Color to keep playing. Happy to test a fix if needed. Thanks!