Page 1 of 1

Cannot change the color of an entity

Posted: Mon Jul 19, 2021 7:32 pm
by XaLpHa89
I can't change the color of a turret, but I can change the color of a character. Why can't I assign a new color to a turret?

Code: Select all

/c game.permissions.get_group( 'Default' ).set_allows_action( defines.input_action.set_entity_color, true )
/c game.permissions.get_group( 'Default' ).set_allows_action( defines.input_action.set_player_color, true )
/c game.surfaces.nauvis.create_entity( { name = 'character', position = { 0, 0 }, force = 'player' } )
/c game.surfaces.nauvis.create_entity( { name = 'gun-turret', position = { 2, 2 }, force = 'player' } )
/c game.player.selected.color = { r = 255, g = 255, b = 0 }
/color blue
20210719210210_1.jpg
20210719210210_1.jpg (92.36 KiB) Viewed 1745 times

Re: Cannot change the color of an entity

Posted: Mon Jul 19, 2021 9:38 pm
by Pi-C
Turrets aren't among the entities that support LuaEntity.color:
color :: Color [Read-Write]

The character, rolling stock, train stop, car, spider-vehicle, flying text, corpse or simple-entity-with-owner color. Returns nil if this entity doesn't use custom colors.

Note: Car color is overridden by the color of the current driver/passenger, if there is one.
EDIT: You can set a turret color during the data stage. A dirty workaround would be to define several turret prototypes with different colors and swap the entities during the control stage.

Re: Cannot change the color of an entity

Posted: Tue Jul 20, 2021 4:52 am
by ssilk
moved from suggestions to modding interface requests

Re: Cannot change the color of an entity

Posted: Wed Jul 21, 2021 5:01 am
by Honktown
From chatting with some devs, the color of turrets is based on the "first" player of a force. Unfortunately, that's it.

Here's a related post: viewtopic.php?t=82644