LUA - Config - How to get Performance Class?

Discussion in 'Content Creation' started by Dagalufh, Jul 27, 2017.

  1. Dagalufh

    Dagalufh
    Expand Collapse

    Joined:
    Feb 14, 2014
    Messages:
    101
    Hi

    Using the function "vehicles.getConfigList().configs" to get a list of configs, how can i get what performance class the vehicle/config has?

    Thanks in advance
    Dagalufh
     
  2. Dagalufh

    Dagalufh
    Expand Collapse

    Joined:
    Feb 14, 2014
    Messages:
    101
    Solved it, so this can be deleted.
     
  3. BombBoy4

    BombBoy4
    Expand Collapse

    Joined:
    May 16, 2015
    Messages:
    1,601
    How did you solve it? Could help others.
     
  4. Dagalufh

    Dagalufh
    Expand Collapse

    Joined:
    Feb 14, 2014
    Messages:
    101
    Yeah, sure. Will post in a bit when i'm at my computer.

    And it can be seen in the new mod that will soon be in the repository. :)

    But, will add it here ofcourse. :)
    --- Post updated ---
    So, lets see if i can explain:
    Code:
    -- First, get a list of all configurations
    local configList = vehicles.getConfigList().configs
    
    -- Iterate through them with a for-loop
    for _, config in pairs(configList) do
        -- Performance Class is a property of a config object, but since it has a space in it, you need to access it through brackets instead of a dot notation
        if (tonumber(config["Performance Class"]) >= 4) then
            -- Do something if the current configurations Performance Class is equal to or bigger than 4.
        end
    end
    
    Hope this is somewhat clear. :)
     
  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