Getting the name of the Tires from M.Wheels

Discussion in 'Programming' started by ryakra, May 22, 2021.

  1. ryakra

    ryakra
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    213
    so I want to get the name of the tire part (not RR/RL/ETC) as a string so I can find the type of tire on the specific wheel. I tried checking dump(M.Wheels) but it doesnt seem to store the part names. I can get stuff like the pressure group or tread nodes, but I dont know if those are able to resolve the name.

    I feel like im being dumb and missing an obvious way.
     
  2. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    This goes through the list of parts on the vehicle and finds the part name prefixed with "tire" and prints it (only works in Game Engine Lua).

    Code:
    for slot, part in pairs(extensions.core_vehicle_manager.getPlayerVehicleData().chosenParts) do
       if part:find("tire") then
          print(part)
       end
    end
     
    #2 angelo234, May 22, 2021
    Last edited: May 22, 2021
  3. ryakra

    ryakra
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    213
    Im currently at the vehicle level since im trying to assign this 'tire name' string to a custom variable that is on the tire itself, it would be run at the same time as init/resetting the wheel itself. Forgot to specify that my b
     
  4. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Hopefully this helps then:

    Code:
    for part, data in pairs(v.data.activeParts) do   
        if part:find("tire") then     
            print(data.information.name)   
        end
    end
     
  5. ryakra

    ryakra
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    213
    that indeed helped!
    there was some weirdness with the part names on the tire but my code ended up being

    Code:
          for part, data in pairs(v.data.activeParts) do   
                if part:find("tire") then     
                    if part == wd.partOrigin:gsub("wheeldata", "tire") then
                        print(data.information.name)
                        rubber = data.information.name
                    end
                end
           end

    the string is assigned and tracked with the tire and done once when wheels get init'd. Thanks for the help!
     
    • 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