1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.37 Bug Reporting thread
    Solutions and more information may already be available.

SOLVED Non-Soundscape Horns?

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by General_Cool, Oct 24, 2025 at 9:40 PM.

  1. General_Cool

    General_Cool
    Expand Collapse

    Joined:
    Jul 29, 2014
    Messages:
    12
    Disclaimer: I am NOT a coder and I have ZERO experience with LUA or FMOD, this is just something I observed while screwing around; hence why I am asking why it isn't as simple as I think it is.

    I recently made a horn mod and had the classic fade out that occurs with all non-FMOD sounds. I started looking into it and found a thread discussing stopSFX vs cutSFX as a solution. After testing and finding that didn't change anything for me (it was a five year old thread; the files have probably changed since then), I realized that electrics.lua defines two types of horns: hornSound1 or sounds.createSoundscapeSound("horn").

    From this, I presume "hornSound1" is the value used by the game for vanilla horns and sounds.createSoundscapeSound("horn") is the one used by mods, like the one I just made, that contain a jbeam file with "soundscape_siren".

    My questions are, why is it not possible to simply create a horn mod that acts like a vanilla horn? If the vanilla horns are FMOD, then why is it not possible to simply copy the file for a horn and modify the wav file it uses? Are the vanilla horns baked into the game engine and inaccessible to players? I understand FMOD modding is not currently compatible with the game for many reasons based on an old thread from a dev I found, but why is it not possible to just copy a file that already exists and just change the audio source it draws from? And finally, why isn't it possible to modify the length of the fade out for soundscape files in one of the lua files?

    Obviously if it was possible it would have been done by now, either by the devs or the modding community, but I am still curious if there is at least some type of scuffed/unstable/sketchy workaround available just by modifying the lua files or by tricking the game into seeing a custom horn as a vanilla horn. I'm new to jbeam and lua and still trying to learn the basics of both.
     
  2. Hasservern

    Hasservern
    Expand Collapse

    Joined:
    Oct 13, 2022
    Messages:
    201
    I truthfullt dont know much about Jbeam either myself, but I believe RenAzuma's gavril durham have a custom horn that isnt like usual horn mods, it uses lua or smth and it behaves like vanilla horn (eg have the start of a horn, the looped part, and the cutoff when the horn isnt pressed anymore) I tried tinkering it myself so it works on other cars but it never works.
     
  3. General_Cool

    General_Cool
    Expand Collapse

    Joined:
    Jul 29, 2014
    Messages:
    12
    Thanks for pointing me in that direction. What did you try that didn't work?

    I just tested the truck in game to see if the horns work and they still do, meaning the code will still work if applied to something else properly, at least as of v0.37. From looking in the files, you can see a "generic_truckhorn_start_loop.wav" and a "generic_truckhorn_end.wav". The start file obviously has the full audio of the horn that loops, while the end file has an extremely short version of the horn that is less than a fifth of a second long.

    From looking at the two files "mdutyHorn.lua" and "soundscape_mduty.jbeam", it appears that what the code did was have the game play a file called "empty.ogg" for its soundscape horn (the type that mods use), and deferred to mdutyHorn.lua for the code that plays the horn like a vanilla one would play. It appears that, in the jbeam file, the code is:

    {
    "soundscape_horn_generic_truck": {
    "information":{
    "authors":"BeamNG",
    "name":"Truck Air Horn 1",
    },
    "slotType" : "soundscape_horn",
    "soundscape": [
    ["name", "src"],
    ["horn", "art/sound/misc/empty.ogg"],
    ],
    "controller" : [
    ["filename"],
    ["mdutyHorn"]
    ],
    "mdutyHorn" : {
    "hornPath": "art/sound/misc/generic_truckhorn_start_loop.wav", //start sound integrated
    "internalHornName": "mduty_horn",
    //"hornStartPath": "vehicles/man/customsounds/kriechbaum/man_horn_2_start.wav",
    //"internalHornStartName": "mduty_horn_start",
    "hornStopPath": "art/sound/misc/generic_truckhorn_end.wav",
    "internalHornStopName": "mduty_horn_stop",
    "startDelay": 0.1,

    "hornVolume": 4,
    "hornPitch": 1,

    "soundNode:":["rf1l"]

    "airhornAllowed": false
    }

    The code is similar for the other horns included in the mod.

    Unfortunately, this is where I am now getting stuck. I do not see anywhere in the folder a file named "man_horn_2_start.wav"; in fact, I do not even see the so called /man/ folder inside of the vehicles folder, it simply doesn't exist. I can see the "generic_truckhorn_end.wav" and the "empty.ogg" in art/sound/misc. I am wondering if that wav is something that is built into the game engine and is what vanilla horns use as their "header" for the audio. If that is the case, how the heck is jbeam or lua file determining which audio file to pull from? I found a reference to the file in mdutyHorn.lua too:

    hornPath2 = jbeamData.hornPath2 or "vehicles/man/customsounds/empty.ogg" -- essentially disables sound, but also requires empty.ogg file!
    hornName2 = jbeamData.internalHornName2 or "MAN_airhorn_2"
    hornStartPath2 = jbeamData.hornStartPath2 or "vehicles/man/customsounds/empty.ogg"
    hornStartName2 = jbeamData.internalHornStartName2 or "MAN_airhorn_start_2"
    hornStopPath2 = jbeamData.hornStopPath2 or "vehicles/man/customsounds/empty.ogg"
    hornStopName2 = jbeamData.internalHornStopName2 or "MAN_airhorn_stop_2"

    It looks like this code is also referencing a file in a folder that doesn't exist (at least in the mod file), and makes no reference to the actual file of the horn that is plays.

    Based on the threads regarding FMOD on this site and the original thread regarding siren fade out, it appears @Diamondback would have knowledge on this topic. @DaddelZeit is listed in the credits for the Durham as the author of the horn lua file, so perhaps they would have knowledge on what the code is specifically doing and how it could be modified.
     
  4. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,479
    It was originally made for the MAN truck mod so references to it are all over the place. That Lua code completely avoids the vanilla horns and Lua logic and just plays the sound itself. It doesn't have a fadeout because it's actually 3 samples, one for start, one for loop and one for end. I think Ren moved the horn start into the loop file and just made that super long to avoid breaks in the sound during transition (caused by too slow of a game update tick).

    Once the horn isn't pressed anymore the code cuts the loop sound and plays the end sound once. You shouldn't need to modify anything except the file paths in JBeam.
     
  5. General_Cool

    General_Cool
    Expand Collapse

    Joined:
    Jul 29, 2014
    Messages:
    12
    Amazing, thanks for the response!

    I went ahead and made a longish loop for the horn as well as a short end for it and a start (3 separate files), then changed up the file paths in the jbeam file and added it to my mod. I also made sure to add lua/controller/mdutyHorn.lua to the vehicles/common folder as well. Unfortunately, the horn doesn't appear in the game. Did I miss something from the original jbeam? I did not copy over the list of available sounds since it looks like it was commented out with /*. Looking further down the list at the code I did copy, it appears hornStartPath and internalHornStartName are both commented out with // as well. Could this be the problem?

    I've left the zip here containing the horn. If you wouldn't mind taking a look I'd appreciate it. I modified the jbeam file with the new path names and also modified the lua to update the folder path that it would look for empty.ogg in. I also put the jbeam into vehicles/common/sounds instead of just leaving it in vehicles/common (like in the Durham mod) since I thought that would cause issues in the game.
     

    Attached Files:

  6. Hasservern

    Hasservern
    Expand Collapse

    Joined:
    Oct 13, 2022
    Messages:
    201
    That is exactly what I meant with the horn doesnt work on all cars, the furthest I got is to make the horn shows up as a selectable on the horn slot but it never plays the audio despite me putting it in a dummy mod that only contains the horn stuff, and on the durham mod itself and putting all the horn related stuff to common folders. As I said Im not a huge expert in coding after all, but I really do wanna make my own personal horn mods that uses this similar technique.
     
  7. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,479
    It does, though?
    upload_2025-10-26_17-8-39.png
    This path will never be checked. If you want to use that controller, give it a unique name and move it to /lua/vehicle/controller. Make sure the name in JBeam matches the new name.
     
  8. General_Cool

    General_Cool
    Expand Collapse

    Joined:
    Jul 29, 2014
    Messages:
    12
    I guess I must have not hit CTRL + R and/or CTRL + L when testing, sorry about that.

    I did not realize that about the pathing. I switched up where everything was and changed the names as per your advice and its working flawlessly now. Thank you so much for the help!

    Unfortunately, I've come across another problem now. I am trying to reuse the code for the sirens now and even though I have reconfigured the jbeam code to say soundscape_siren instead of soundscape_horn, the game is now treating the siren, which is selected from the siren slot, as a horn that is activated with H. When the lightbar is activated twice for sirens, it makes no noise. I am assuming this is because of the lua file the jbeam file references, but I am not quite sure what to do. There is 171 mentions of the word "horn" in that file, and I am assuming it is not as simple as doing find all and replace with the word siren. I cannot find any file named mdutySiren.lua in the Durham mod, so I am assuming the author used the base game sirens. In the lua I can tell hornSound1 and hornSound2 are referencing the electrics.lua file which contain the same references. That lua file also contains a sirenSound reference, which I assume is what I am looking for. Unfortunately, I do not have enough lua knowledge to know what to do here, but I will try tinkering for now. Any ideas?
    --- Post updated ---
    See my above message, I got it to work with horns. Once I troubleshoot the siren issue I will probably release a template for other modders to use, provided I have the right permissions (after all, none of this is my own code).
     
  9. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,479
    That Lua code is mine. It entirely replaces the horn logic and is not applicable at all to sirens or anything else. You'd likely be able to do something similar, but you'd need to change how the sound is activated through Lua.
     
  10. General_Cool

    General_Cool
    Expand Collapse

    Joined:
    Jul 29, 2014
    Messages:
    12
    What part of the file determines how the horn is activated and deactivated by key press? I'm looking through and I don't see anything that references an activation by keystroke, but I do see an "if electrics.values.horn == 1 then" statement; is "electrics.values.horn" what the game calls the horn key internally? I also see an "if electrics.values.hornIndex == 0 then" statement but I am not quite sure what this does since the code for the previous statement also contains an else statement which stops the horn and plays the stop horn sound file (correct me if I am understanding this wrong). I am assuming whatever the file is referencing for horn activation by keystroke can be modified based on code in the electrics.lua file that says "toggleSound(lightbarState == 2, sirenSound)".
     
  11. General_Cool

    General_Cool
    Expand Collapse

    Joined:
    Jul 29, 2014
    Messages:
    12
    @DaddelZeit One quick and final update on this; I messed around with the lua by changing all the references to electrics.values.horn to siren as well as changing all the horn references to siren and everything works perfectly now. I used the electrics.lua as a reference for lightbar states since I figured it followed the same logic as horns and it does. Thank you so much for your help with the horn aspect of things since it helped me to understand the lua better to modify the files for usage with sirens. I'll mark this thread as solved now. :)
     
  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