How to get the current part for a slot

Discussion in 'Programming' started by SouthernPotato, Mar 27, 2025.

  1. SouthernPotato

    SouthernPotato
    Expand Collapse

    Joined:
    Feb 7, 2016
    Messages:
    123
    Is there any convenient way to get the part for a given partname in lua? Something like core_vehicle_magic.getPartNameAtSlot('wheel_F_5')

    I'm building that explores, displays, and lets you configure car parts, specifically wheels and tires. Right now it looks through the whole parts config to find the suspension, and from there goes to hubs, wheels and tires.

    I've run into several issues by doing this from the parts config - since default parts can be omitted from the part config, the key may not be in the config. For instance if you load the default Bruckel Nine and do

    vehData = core_vehicle_manager.getVehicleData(be:getPlayerVehicle(0):getID())
    mySuspensionName = vehData.config.parts.nine_suspension_F


    Then mySuspensionName will just be nil, even though the car does of course have its suspension in this slot. Even if you get the default parts config, the Nine still doesn't explicitly mention a suspension
     
  2. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,472
    This works.
    Code:
    vehData = core_vehicle_manager.getVehicleData(be:getPlayerVehicle(0):getID())
    mySuspensionName = vehData.chosenParts.nine_suspension_F
     
    • Like Like x 1
  3. SouthernPotato

    SouthernPotato
    Expand Collapse

    Joined:
    Feb 7, 2016
    Messages:
    123
    Man that's so simple, surprised I didn't stumble into that. Thanks!
     
  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