LuaEntity.color can also get/set the color of locomotive

Things that already exist in the current mod API
Post Reply
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1194
Joined: Wed May 18, 2016 4:55 pm
Contact:

LuaEntity.color can also get/set the color of locomotive

Post by Mooncat »

I wish LuaEntity.color can also link to the color of locomotive.

A player suggested to implement my Color Picker for changing locomotive color. But when I attempted to get the opened locomotive's color, it returns nil. So I don't know how to get and set the color now.

PS: according to the document, "The character or rolling stock color", so I think it is also supposed to link to the colors of car and tank? But now it is also nil when I get their colors. character.color works however. :?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaEntity.color can also get/set the color of locomotive

Post by Rseding91 »

The color property for LuaEntity returns nil if the locomotive/train doesn't have a custom color set.

If it has one set it returns the color value that it's set too.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1194
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: LuaEntity.color can also get/set the color of locomotive

Post by Mooncat »

I see... what if it provides the default (prototype) color instead of nil in that case? If it is nil, I will have to assume that the locomotive has default color of Red. Unfortunately, FARL provides a locomotive with default color of Yellow. So the assumption will be wrong. And it seems there is no color property in LuaEntityPrototype. :?

If it is implemented, is it also possible to make that changing LuaEntity.color will also update the GUI? :P
I have checked that it doesn't update the GUI now.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: LuaEntity.color can also get/set the color of locomotive

Post by aubergine18 »

Mooncat wrote:If it is implemented, is it also possible to make that changing LuaEntity.color will also update the GUI? :P
I have checked that it doesn't update the GUI now.
IMO the GUI colour should not be based on player colour (and if it was, maybe only the toolbar above the minimap).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1194
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: LuaEntity.color can also get/set the color of locomotive

Post by Mooncat »

aubergine18 wrote:
Mooncat wrote:If it is implemented, is it also possible to make that changing LuaEntity.color will also update the GUI? :P
I have checked that it doesn't update the GUI now.
IMO the GUI colour should not be based on player colour (and if it was, maybe only the toolbar above the minimap).
It isn't related to player color. I meant the GUI for changing locomotive's color. The one that has 3 scrollbars, with an image of the locomotive at the left side.

Post Reply

Return to “Already exists”