Custom Color

by DiRten

More Colors for Vehicles, Players, Trains, Train Stops, Tanks, Cargo Wagons, Fluid Wagons, Spidertrons - RGB color picker with saturation control - Copy/Paste colors (Shift + Right Click → Shift + Left Click) *Vehicle color is independent of player color*

Utilities
2 months ago
1.1 - 2.0
4.45K
Transportation Trains

g Error while running event CustomColor::on_gui_value_changed (ID 90)

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

The mod crashes every time I try to set a custom color, either by clicking on the RGB sliders or inside the input boxes to manually input RGB values, error message is:

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

Error while running event CustomColor::on_gui_value_changed (ID 90)
CustomColor/libraries/functions/color.lua:55: attempt to index field '?' (a nil value)
stack traceback:
CustomColor/libraries/functions/color.lua:55: in function 'set_color'
CustomColor/libraries/gui/interactions.lua:81: in function <CustomColor/libraries/gui/interactions.lua:58>
(...tail calls...)

Factorio 1.1.110 standalone (downloaded from website).
Intel i9-13900K, NVIDIA 4070 - driver 535.183.01, OS: Linux MX (Debian 12), DE: XFCE 4.18 (GTK 3.24.38).

EDIT: list of installed mods: Automatic Train Painter, Clean Floor, Dectorio, Far Reach, Nanobots, Void.

21 days ago

Same error, trying to edit player color wearing mech armor

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

Error while running event CustomColor::on_gui_value_changed (ID 104)
CustomColor/libraries/functions/color.lua:65: attempt to index field '?' (a nil value)
stack traceback:
CustomColor/libraries/functions/color.lua:65: in function 'set_color'
CustomColor/libraries/gui/interactions.lua:57: in function <CustomColor/libraries/gui/interactions.lua:27>
(...tail calls...)

17 days ago
(updated 17 days ago)

Note: I haven't checked if the 2.0 version is working

Unzip the mod, edit CustomColor/libraries/init.lua

Factorio 1.1 (mod version 3.1.2)

Change this part:

script.on_init(function()
    global.car_catalog = {}
    global.player_info = {}
    for _, v in pairs(game.players) do
        gui_create(v)
    end
end)

To this:

script.on_init(function()
    global.car_catalog = {}
    global.player_info = {}
    for _, v in pairs(game.players) do
        global.player_info[_] = {color = v.color}
        gui_create(v)
    end
end)

Factorio 2.0 (mod version 3.2.1)

Change this part:

script.on_init(function()
    storage.car_catalog = {}
    storage.player_info = {}

    for _, v in pairs(game.players) do
        --gui_create(v)
    end
end)

To this:

script.on_init(function()
    storage.car_catalog = {}
    storage.player_info = {}

    for _, v in pairs(game.players) do
        storage.player_info[_] = {color = v.color}
        --gui_create(v)
    end
end)

Then you need to remove the mod, load the save, overwrite the save, add the mod back, then it should be fixed.
There are other ways to fix that doesn't involve removing the mod first, but I'm not a modder so I'm not sure what the best practices are.

Explanation:
script.on_init runs when the mod is just added to the save (it won't run again afterwards, until it gets removed first). Here the mod just sets empty default values, and assumes updates will take care of new players.
However when we look at CustomColor/libraries/events.lua, the mod checks for on_player_created (runs on new player creation) and on_player_joined_game (runs on multiplayer join, not singleplayer load). That means if we load an already existing save the data will simply be missing, hence the error.
The way I fixed it is by changing script.on_init to immediately load all available player color data instead of delegating it to update.

New response