Cannot change the color of an entity

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
XaLpHa89
Fast Inserter
Fast Inserter
Posts: 119
Joined: Wed Jan 24, 2018 6:59 am
Contact:

Cannot change the color of an entity

Post 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 1374 times

Pi-C
Smart Inserter
Smart Inserter
Posts: 1656
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Cannot change the color of an entity

Post 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.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Cannot change the color of an entity

Post by ssilk »

moved from suggestions to modding interface requests
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Honktown
Smart Inserter
Smart Inserter
Posts: 1026
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Cannot change the color of an entity

Post 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
I have mods! I guess!
Link

Post Reply

Return to “Modding interface requests”