Custom Color

by DiRten

More Colors for Vehicles, Players, Trains, Train Stops, Tanks, Cargo-wagons, Fluid-Wagons, Spidertrons -RGB value (Including color saturation) -Copy/Paste color (Shift-RMB -> Shift-LMB) *Vehicle don't change color with player*

Utilities
10 months ago
1.1
1.60K
Transportation Trains

g Vehicles cause game to crash

1 year, 1 month ago

As soon as I get out of a tank or car, the game crashes with the following:

The mod Custom Color (3.1.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event CustomColor::on_player_driving_changed_state (ID 28)
CustomColor/libraries/functions/cars.lua:46: attempt to index field '?' (a nil value)
stack traceback:
CustomColor/libraries/functions/cars.lua:46: in function <CustomColor/libraries/functions/cars.lua:38>

This does not happen if I ride in a train, I haven't tested this with the spidertron yet.

1 year, 19 days ago
(updated 1 year, 19 days ago)

I experienced the same crash after adding the mod to an existing single-player game. The problem is that in single player mode, on_player_joined_game will be raised only once (directly after on_player_created), not when loading a saved game. The only place where player data could be initialized in this case would be in on_configuration_changed, but the mod only migrates tables there and doesn't create new ones. (@DiRten: By the way, why didn't you use migration files? Each migration file will be run only once, not each time a mod has been changed.)

I've fixed the crash by replacing lines 26 and 27 of libraries/update.lua with this:

for _, v in pairs(game.players) do
    global.player_info[v.index] = global.player_info[v.index] or {color = v.color}
    if v.gui.relative.player_color_sprite_button_open ~= nil then
1 year, 19 days ago

I apologize, I am rather new to modding with Factorio and wasn't fully aware of using migration files.

1 year, 19 days ago
(updated 1 year, 19 days ago)

I apologize, I am rather new to modding with Factorio and wasn't fully aware of using migration files.

Sorry, my bad: That was meant for @DiRten! Migration files are part of the mod. I've edited my first post to make this more obvious. :-)

1 year, 18 days ago

Ha! No worries. Had me going for about 10 minutes scratching my head wondering why I didn't use migration files and spent another 10 minutes researching the topic....

10 months ago

I experienced the same crash after adding the mod to an existing single-player game. The problem is that in single player mode, on_player_joined_game will be raised only once (directly after on_player_created), not when loading a saved game. The only place where player data could be initialized in this case would be in on_configuration_changed, but the mod only migrates tables there and doesn't create new ones. (@DiRten: By the way, why didn't you use migration files? Each migration file will be run only once, not each time a mod has been changed.)

I've fixed the crash by replacing lines 26 and 27 of libraries/update.lua with this:

for _, v in pairs(game.players) do
global.player_info[v.index] = global.player_info[v.index] or {color = v.color}
if v.gui.relative.player_color_sprite_button_open ~= nil then

Thanks for the help! I'll be doing this in the near future.

8 months ago
(updated 8 months ago)

I did exactly what you said for the fix, now I'm getting this:

CustomColor/control.lua:19: CustomColor/libraries/update.lua:42: ')' expected (to close '(' at line 1) near 'for'
stack traceback:
[C]: in function 'require'
CustomColor/control.lua:19: in main chunk

What am i dong wrong?

8 months ago

you can disregard, got it working

New response