Facepunch / garrysmod-requests

Feature requests for Garry's Mod
84 stars 24 forks source link

Make a way to create soundscapes via Lua #488

Open ghost opened 9 years ago

ghost commented 9 years ago

There's no way to package a .txt soundscape file with an addon, and so I think there should be some other way to create a custom soundscape, perhaps with lua.

"degenerate_outdoors_storm"
{
    "playlooping"
    {
        "volume"    "1"
        "pitch"     "100"
        "wave"      "ambient/weather/rumble_rain_nowind.wav"
    }

    "playrandom"
    {
        "time"      "8, 14"

        "volume"    "1"

        "pitch"     "120"

        "rndwave"
        {
            "wave"  "ambient/atmosphere/thunder1.wav"
            "wave"  "ambient/atmosphere/thunder2.wav"
            "wave"  "ambient/atmosphere/thunder3.wav"
            "wave"  "ambient/atmosphere/thunder4.wav"
        }

    }

}
robotboy655 commented 9 years ago

Once again, are we talking about soundSCRIPTS or soundSCAPES? You should rename all your open threads to clarify this.

ghost commented 9 years ago

soundSCAPE. Always confuse the two.

robotboy655 commented 9 years ago

nonononon, let me clarify, what sound.Add does is soundSCRIPTS. What you seem to want is soundSCAPES which is not sound.Add is.

You can open scripts/ folder of any source engine game and see soundscripts which only have what sound.Add allows and then there are soundscapes which has all the playrandom & playlooping stuff.

ghost commented 9 years ago

This is a confusing mess, isn't it now?

robotboy655 commented 9 years ago

Tell you what, try putting your soundscape file into the .bsp and try loading it with http://wiki.garrysmod.com/page/sound/AddSoundOverrides

ghost commented 9 years ago

Added scripts/soundscapes_degenerate.txt (and soundscapes_degenerate.txt to be safe) to the bsp, and loaded it with sound.AddSoundOverrides in my file autorun/client/soundscapes.lua

sound.AddSoundOverrides( "scripts/soundscapes_degenerate.txt" )

Soundscape txt:

"degenerate_outdoors_storm"
{
    "playlooping"
    {
        "volume"    "1"
        "pitch"     "100"
        "wave"      "ambient/weather/rumble_rain_nowind.wav"
    }

    "playrandom"
    {
        // time, volume, pitch, attenuation are all random intervals ( i.e. minval, maxval )
        // every 4 to 7 seconds
        "time"      "8, 14"

        // at a volume of 1 (%100)
        "volume"    "1"

        // at a pitch of 100
        "pitch"     "120"

        // play one of these .wav files randomly each time
        "rndwave"
        {
            "wave"  "ambient/atmosphere/thunder1.wav"
            "wave"  "ambient/atmosphere/thunder2.wav"
            "wave"  "ambient/atmosphere/thunder3.wav"
            "wave"  "ambient/atmosphere/thunder4.wav"
        }

    }

}

When calling up degenerate_outdoors_storm using an env_soundscape, it did not play.

robotboy655 commented 9 years ago

Ok, I looked into the soundscape file loading, try PakRat'ing scripts/soundscapes_gm_degenerate.txt into your map. The important bit is the gm_ part.

According to the code, it loads scripts/soundscapes_<exact_map_name>.txt from the filesystem. If that doesn't work, try putting scripts/soundscapes_gm_degenerate.txt into garrysmod folder where you'd put the manifest file.

Let me know the results.

ghost commented 9 years ago

Packing it into the map with the new name didn't work. What do you mean by "manifest" format? I did have it in scripts.

robotboy655 commented 9 years ago

In your .bsp:

scripts/soundscapes_gm_degenerate.txt

"degenerate_outdoors_storm"
{
    "playlooping"
    {
        "volume"    "1"
        "pitch"     "100"
        "wave"      "ambient/weather/rumble_rain_nowind.wav"
    }

    "playrandom"
    {
        // time, volume, pitch, attenuation are all random intervals ( i.e. minval, maxval )
        // every 4 to 7 seconds
        "time"      "8, 14"

        // at a volume of 1 (%100)
        "volume"    "1"

        // at a pitch of 100
        "pitch"     "120"

        // play one of these .wav files randomly each time
        "rndwave"
        {
            "wave"  "ambient/atmosphere/thunder1.wav"
            "wave"  "ambient/atmosphere/thunder2.wav"
            "wave"  "ambient/atmosphere/thunder3.wav"
            "wave"  "ambient/atmosphere/thunder4.wav"
        }

    }

}
ghost commented 9 years ago

Alright, that worked flawlessly. Thanks for putting up with me this long >.>

pizzadox11 commented 4 years ago

Read the latest command if you get troubles with custom soundscapes or custom particles https://github.com/Facepunch/garrysmod-issues/issues/3314

URAKOLOUY5 commented 1 month ago

Without packing to BSP or whitelist soundscape files🫤