Page 1 of 1

Problems with setting color of a car

Posted: Mon May 04, 2020 8:27 pm
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?

Re: Problems with setting color of a car

Posted: Tue May 05, 2020 11:43 am
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.