From Pragma
Jump to: navigation, search


Pragma supports three sound formats, .wav and .ogg.
Note: .mp3-support is currently disabled due to high licensing costs!

All sounds have to be located in the "sounds"-directory, or a sub-folder of it.
To play a sound it has to be precached first. If you attempt to play a non-precached sound, a warning will be thrown in the console.
Sounds which have been used in a soundscript, or via an env_sound entity, will be precached automatically, as well as if you play it using the "sound_play" console command. In other cases you have to use sound.Precache before playing it.

If a sound is stereo, it cannot be played as a world sound. In this case you can either convert the actual sound-file to mono, or let the engine do it for you when the sound is precached. See sound.Precache for more information.

There are various ways to play a sound:
sound_play (Console)
"sound_play" is a console command, which immediately precaches and plays the specified sound. The command shouldn't really be used for anything but testing purposes.
env_sound (Map)
If you want to create a sound in your map, you can use the "env_sound" entity.
sound.Create / sound.Play (Lua)
To play a sound via a lua-script, you can use the sound.Create and sound.Play functions. They will not automatically precache the sound, so you will have to do that manually beforehand.


Instead of using a direct path to a sound, you can use the name of a sound-script. This has various advantages, e.g. you can play a random sound from a list with just one identifier, or having additional effects applied to a sound automatically.
All soundscript-files should be located inside 'scripts/sounds'. Before being able to use any of the soundscripts from the file, you'll have to precache it first using sound.LoadScripts.
A typical soundscript is defined like this:


"fx.fst_grass" is the name that can be used instead of a path when playing or creating a sound. The "soundlist" contains a list of sounds from which a random sound will be picked.