Problems with setting color of a car
Posted: Mon May 04, 2020 8:27 pm
This used to work:
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):
This is what I see in the log:
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?
Code: Select all
if vehicle.valid then
vehicle.color = game.players[owner].color
end
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
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}