Solved About the location of the cars

Discussion in 'Mod Support' started by NiZhaZi, Jan 21, 2024.

  1. NiZhaZi

    NiZhaZi
    Expand Collapse

    Joined:
    Apr 1, 2023
    Messages:
    14
    How can I get the cars' location on the map from lua?Thanx.
     
  2. daniel-w

    daniel-w
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 28, 2017
    Messages:
    284
    You can do the following:
    Code:
    local veh = be:getObjectByID(vehID) -- You have to specify the vehicle ID
    -- To get your current vehicle, you can do:
    veh = be:getPlayerVehicle(0)
    
    -- You can then print/dump it like so:
    dump(veh)
    
    -- From the output of the dump, you should see the function "getPosition", so to call it, you can do:
    dump(veh:getPosition()) -- Will return "vec3(x, y, z)"
    
     
  3. NiZhaZi

    NiZhaZi
    Expand Collapse

    Joined:
    Apr 1, 2023
    Messages:
    14
    Thank you very much for this
     
  4. daniel-w

    daniel-w
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 28, 2017
    Messages:
    284
    No worries, good luck :)
     
  5. NiZhaZi

    NiZhaZi
    Expand Collapse

    Joined:
    Apr 1, 2023
    Messages:
    14
    It seems that be can't be used in lua files under the folder "vehicles", how can I use it in the files inder "vehicles"
     
  6. daniel-w

    daniel-w
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 28, 2017
    Messages:
    284
    If it's vehicle lua, you can use "obj:getPosition()". Call "dump(obj)" in the vehicle lua from the console, it will show you all the available functions
     
  7. NiZhaZi

    NiZhaZi
    Expand Collapse

    Joined:
    Apr 1, 2023
    Messages:
    14
    It solved, Thanx!
     
    • 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