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

b Crash when entering a vehicle after creating a new color template, saving and applying it

10 months ago

This is the error message:

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:44: attempt to index field '?' (a nil value)
stack traceback:
CustomColor/libraries/functions/cars.lua:44: in function <CustomColor/libraries/functions/cars.lua:38>

It's my first time submitting an error report for a factorio mod, let me know if there's other resources you need please.
I have a bunch of mods installed, based on this modpack https://mods.factorio.com/mod/Future-Technology-Factorio-Modpack-IR3/downloads to which i added just a few QOL mods. The only color mod i added is this https://mods.factorio.com/mod/Oil_Based_Paint, right before adding Custom Color to it.

10 months ago

Looking at the code, it seems global.player_info hasn't been set yet for the player. I think changing line 44 of libraries/functions/cars.lua from

                script.raise_event(mod_get_event("car_paint_player").id, {player = current_player, player_saved_color = global.player_info[event.player_index].color, entity = event.entity})

to

            script.raise_event(mod_get_event("car_paint_player").id, {player = current_player, player_saved_color = global.player_info[event.player_index] and global.player_info[event.player_index].color or nil, entity = event.entity})

would fix that. Just unzip the mod and edit the file, then restart the game. Unpacked mods take precedence over zipped mods, so your changed version will be used until the mod is updated.

New response