entities.color: add car to entities

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

entities.color: add car to entities

Post by Pi-C »

I'd like to set the color of entities with type == "car" to always be the color of a certain player, whether the car is empty or whether anybody is in it. Here is a more detailed description.

According to the wiki, the car is not among the entities that allow to set the color. Could you add it, please?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: entities.color: add car to entities

Post by darkfrei »

+1

It's not synced between car color and player color, if the player changes his color, the color of the car will be not changed. The car has own color!
2019-09-22T12_35_39-Window.png
2019-09-22T12_35_39-Window.png (78.19 KiB) Viewed 1574 times
2019-09-22T12_35_52-Window.png
2019-09-22T12_35_52-Window.png (88.61 KiB) Viewed 1574 times

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

Re: entities.color: add car to entities

Post by Pi-C »

The car may have its own color, but it is set to the current color of the last player driving it, or the current color of the last player in it:

Make a multiplayer game. Place a car, it will have a neutral color. Let player 1 get inside -- he is the new driver, and the car will have the same color player 1 currently has. Switch users, and enter the same car as player 2. Player 2 is passenger now, the car will still have the color it inherited from player 1. Switch users again. As player 1, leave the car. The car has no driver now, but there still is a passenger (player 2). The car will be recolored using the current color of player 2. Switch users again, and as player 2, leave the car. It will still have the color it had after player 1 left it.

Obviously,, there is a connection between current player color and color of the car. Somehow, this color must be set, and I'm looking for a way to set it from a mod whenever on_player_driving_changed_state is triggered. (Perhaps also if the player changes his own color -- can't look into that now, though. REading glasses are at home, and the sunlight makes reading on this laptop too hard.)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Bilka
Factorio Staff
Factorio Staff
Posts: 3159
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: entities.color: add car to entities

Post by Bilka »

Okay, added for the next version. Keep in mind that passenger color overrides the color that can be set through LuaEntity::color. So, setting a color only applies when the car is empty, otherwise the car will use the passenger color.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

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

Re: entities.color: add car to entities

Post by Pi-C »

Bilka wrote:
Mon Sep 23, 2019 12:45 pm
Okay, added for the next version.
Thank you!
Keep in mind that passenger color overrides the color that can be set through LuaEntity::color. So, setting a color only applies when the car is empty, otherwise the car will use the passenger color.
Am I correct in assuming that vehicle color set per mod will be overridden by a new driver first, and by passenger only if there is no driver? In this case, I could eject any passenger that gets into a car when there is no driver, and recolor the car again.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Bilka
Factorio Staff
Factorio Staff
Posts: 3159
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: entities.color: add car to entities

Post by Bilka »

Passenger/driver is the same to me (when talking about cars in factorio). So, to clarify, both driver and gunner override the color when they're in the car, driver takes priority. The color that you see on the empty car is only set once the player leaves the car, so you can override it after they do that.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

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

Re: entities.color: add car to entities

Post by Pi-C »

Bilka wrote:
Mon Sep 23, 2019 5:08 pm
Passenger/driver is the same to me (when talking about cars in factorio). So, to clarify, both driver and gunner override the color when they're in the car, driver takes priority. The color that you see on the empty car is only set once the player leaves the car, so you can override it after they do that.
I've implemented that now (update hasn't been released yet), and it works great! Vehicles always have the color of the "owner" now, unless the owner isn't inside but somebody else is. As soon as the last player leaves the vehicle, it is recolored again (owner.color if there is an owner, {r=0, g=0, b=0, a=0} otherwise).
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Implemented mod requests”