Problems with setting color of a car

Place to get help with not working mods / modding interface.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1760
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Problems with setting color of a car

Post by Pi-C »

This used to work:

Code: Select all

if vehicle.valid then
	vehicle.color = game.players[owner].color
end
The code is executed now, but the color isn't changed. I've added some logging code (mostly to demonstrate that the entity of which I want to change the color really exists and is of the correct type):

Code: Select all

        
if vehicle.valid then
	log("vehicle.type: " .. tostring(vehicle.type))
	log("vehicle.unit_number: " .. tostring(vehicle.unit_number))
	log("vehicle.color: " .. serpent.line(vehicle.color))

            vehicle.color = {r = 0, g = 0, b = 0, a = 0}

	log("Changed color!")
	log("vehicle.type: " .. tostring(vehicle.type))
	log("vehicle.unit_number: " .. tostring(vehicle.unit_number))
	log("new vehicle.color: " .. serpent.line(vehicle.color))
end
This is what I see in the log:

Code: Select all

vehicle.type: car
vehicle.unit_number: 32
vehicle.color: {a = 1, b = 0.66367208957672119, g = 0.58372372388839722, r = 0.29321792721748352}
Changed color!
vehicle.type: car
vehicle.unit_number: 32
new vehicle.color: {a = 1, b = 0.66367208957672119, g = 0.58372372388839722, r = 0.29321792721748352}
I just scanned the release notes of the of the past few Factorio versions, but didn't see anything regarding colors and cars. Did I miss something again, or is this a bug?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Pi-C
Smart Inserter
Smart Inserter
Posts: 1760
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Problems with setting color of a car

Post by Pi-C »

Pi-C wrote: Mon May 04, 2020 8:27 pm Did I miss something again, or is this a bug?
I missed something: AAI Programmable Vehicle was active during my test, and it places a dummy character into vehicles. Thus, although my own character had left the vehicle, my alter ego was still in it and would override any color I've set.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding help”