QUESTION How to get max gears of a car in python?

Discussion in 'Apps' started by FitbyBit, Mar 17, 2023.

  1. FitbyBit

    FitbyBit New Member

    Joined:
    Jan 10, 2022
    Messages:
    10
    Likes Received:
    4
    I'm trying to figure out how to get "max gears" value for a car.
    This AC API document describes "Gear" property, but there is no kind of "MaxGears" property.

    Code for getting a current "Gear":
    Code:
    current_gear = ac.getCarState(ac.getFocusedCar(), acsys.CS.Gear)
    Is there a way to get max gear's value?
     
  2. fughettaboutit

    fughettaboutit aka leBluem

    Joined:
    Jul 21, 2014
    Messages:
    1,113
    Likes Received:
    378
  3. fughettaboutit

    fughettaboutit aka leBluem

    Joined:
    Jul 21, 2014
    Messages:
    1,113
    Likes Received:
    378
    FitbyBit likes this.
  4. LilyanaCarney

    LilyanaCarney New Member

    Joined:
    Mar 21, 2023
    Messages:
    1
    Likes Received:
    0
    You can use the following code to get the maximum number of car gears in Assetto Corsa:
    max_gears = ac.getCarState(ac.getFocusedCar(), acsys.CS.GearNumGears)

    This property GearNumGears returns the maximum number of gears for the car. You can then use this variable for any needs in a future script.
     
  5. fughettaboutit

    fughettaboutit aka leBluem

    Joined:
    Jul 21, 2014
    Messages:
    1,113
    Likes Received:
    378
    when i try this (ingame oc):

    Code:
    import ac, acsys, traceback
    try:
      max_gears = ac.getCarState(0, acsys.CS.GearNumGears)
    except:
      ac.log('error : ' + traceback.format_exc() )
    
    this comes up in the log:
    Code:
    AttributeError: type object 'CS' has no attribute 'GearNumGears'
    dont use ChatGPT for everything
    snippet from "...steamapps\common\assettocorsa\apps\python\system\acsys.py"
    there is no "GearNumGears" indeed
    upload_2023-3-21_13-17-17.png
     
    Last edited: Mar 21, 2023
    FitbyBit likes this.
  6. fughettaboutit

    fughettaboutit aka leBluem

    Joined:
    Jul 21, 2014
    Messages:
    1,113
    Likes Received:
    378
    Welcome @LilyanaCarney !
     
: gear, python, mod
  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