Solved Changing a vehicles color from Lua

Discussion in 'Mod Support' started by RcCookie, Feb 12, 2023.

  1. RcCookie

    RcCookie
    Expand Collapse

    Joined:
    Feb 24, 2018
    Messages:
    37
    Is there a way to set the vehicle's color from Lua, without any freezing (like don't load a different config)? Should be similar to how the traffic modifies the traffic vehicles' colors.
     
  2. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,404
    Definitely possible, not sure how exactly but you can check the part randomizer mod, it has a button that randomizes colors and it's super fast
     
  3. RcCookie

    RcCookie
    Expand Collapse

    Joined:
    Feb 24, 2018
    Messages:
    37
    Yes, I mean changing the color via UI also happens instantly.
     
  4. meywue

    meywue
    Expand Collapse
    BeamNG Team

    Joined:
    Nov 19, 2015
    Messages:
    346
    this should work in game engine lua:

    Code:
    local vehicleObj = be:getPlayerVehicle(0)
    vehicleObj.color = Point4F(1,0,0,1)
    vehicleObj.colorPalette0 = Point4F(0,1,0,1)
    vehicleObj.colorPalette1 = Point4F(0,0,1,1)
    
    Where the fourth (w) component defines the Chrominess (0.0 = 0%, 2.0 = 100%)
     
    • Like Like x 1
    • Agree Agree x 1
  5. RcCookie

    RcCookie
    Expand Collapse

    Joined:
    Feb 24, 2018
    Messages:
    37
    Thanks, works perfectly!
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice