Unsolved New to LUA, need help loading lua in a mod

Discussion in 'Mod Support' started by Insanity624, Dec 6, 2024.

  1. Insanity624

    Insanity624
    Expand Collapse

    Joined:
    Mar 22, 2024
    Messages:
    5
    I want to add an lua script to play the instantAfterfireSound event upon a certain condition. The first question is how can I get an lua script to load for a car mod, the second is if it is possible to play this fmod event through lua. Thanks in advance for the help.
     
  2. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    60
    If you have a sound file (art/sound/yourSoundName.mp3) you'll be able to test it manually in your vlua console by running the following code (nodeID can be for example 1):
    Code:
    local sound = obj:createSFXSource("art/sound/yourSoundName.mp3", "AudioClosest3D", "", nodeID)
    obj:setVolume(sound, 1)
    obj:playSFX(sound)
    
    To make the Lua code load with your vehicle, you need to create a Lua extension. Documentation: https://documentation.beamng.com/modding/programming/extensions/

    I'd suggest digging into vanilla game files, for example lua\vehicle\sounds.lua, and exploring them.
    From the documentation page:
     
    • 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