1. The BeamNG Team wishes everyone Happy Holidays!
    BeamNG team presence will be limited during the holiday season as we take the time off to rest and enjoy the holidays!
    There will be no mod support or mod approvals from 19th of December until 5th of January. Please expect delays during this period.
    We hope you enjoy the holidays too, see you in 2026!

Unsolved How to spawn a vehicle from lua

Discussion in 'Mod Support' started by jojos38, Aug 15, 2018.

  1. jojos38

    jojos38
    Expand Collapse

    Joined:
    Oct 22, 2013
    Messages:
    1,072
    Hello, I would like to know if it's possible to spawn a specific vehicle from lua ?
    for exemple spawnVehicle("vehicles/pickup")
    Thanks !
     
  2. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Yes, it is possible.

    Examples:
    Code:
    core_vehicles.spawnNewVehicle("pickup",{})
    core_vehicles.spawnNewVehicle("pickup", {config = 'vehicles/pickup/cool.pc'})
    core_vehicles.spawnNewVehicle("pickup", {color = {0.5,0.5,0,1}})
    core_vehicles.spawnNewVehicle("pickup", {color = {0.5,0.5,0,1},color2 = {0.5,0,0.5,1}})
    core_vehicles.spawnNewVehicle("pickup", {config = 'vehicles/pickup/cool.pc',color = {0.5,0,0.5,1},color2 = {0.5,0.5,0.5,1}})
    
    So it's spawnNewVehicle(jbeam_name,options) where jbeam_name is a string and options is an array. For valid stuff to put in the array take a look at the "sanitizeOptions" function in this file:
    Steam\SteamApps\common\BeamNG.drive\lua\ge\extensions\core\vehicles.lua
     
    • Like Like x 2
  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