LuaAudio.wiki
changeset 1800 3e761893a2e9
parent 1799 af459cd65ac6
child 1844 c08180a318f1
equal deleted inserted replaced
1799:af459cd65ac6 1800:3e761893a2e9
     1 #summary List of functions in the Lua API that affect the audio
     1 #summary List of functions in the Lua API that affect the audio
     2 
     2 
     3 = Lua API: Audio functions =
     3 = Lua API: Audio functions =
     4 This page is a list of all functios in the [LuaAPI Lua API] that affect the audio.
     4 This page is a list of all functios in the [LuaAPI Lua API] that affect the audio.
     5 
     5 
     6 == Audio functions ==
     6 == `PlaySound(soundId, [gearUid [, instaVoice]])` ==
     7 === `PlaySound(soundId, [gearUid [, instaVoice]])` ===
       
     8 Plays the specified sound. Possible values for `soundId` are listed on the [Sounds] page.
     7 Plays the specified sound. Possible values for `soundId` are listed on the [Sounds] page.
     9 
     8 
    10 To play a voice (see [Taunts] for a list), you must also set `gearUid`. `gearUid` is the hedgehog gear which is used to “talk”.
     9 To play a voice (see [Taunts] for a list), you must also set `gearUid`. `gearUid` is the hedgehog gear which is used to “talk”.
    11 
    10 
    12 If you play a voice, by default the voice will respect an internal queue and might be played with an delay in order to prevent annoying voice overlapping. Since version 0.9.24, you can disable this behaviour and force Hedgewars to instantly play the voice by also setting `instaVoice` to `true`. Only use `instaVoice` when you really need it.
    11 If you play a voice, by default the voice will respect an internal queue and might be played with an delay in order to prevent annoying voice overlapping. Since version 0.9.24, you can disable this behaviour and force Hedgewars to instantly play the voice by also setting `instaVoice` to `true`. Only use `instaVoice` when you really need it.
    13 
    12 
    14 === `PlayMusicSound(soundId)` (0.9.25) ===
    13 == `PlayMusicSound(soundId)` (0.9.25) ==
    15 Plays a sound as replacement for the background music. The sound is played once. The main music is paused and the sound is played instead. The main background music does not resume automatically, so you should call `StopMusicSound` after a while.
    14 Plays a sound as replacement for the background music. The sound is played once. The main music is paused and the sound is played instead. The main background music does not resume automatically, so you should call `StopMusicSound` after a while.
    16 
    15 
    17 Example:
    16 Example:
    18 <code language="lua">
    17 <code language="lua">
    19 PlayMusicSound(sndRideOfTheValkyries) -- Replace the background music the Ride of the Valkyries
    18 PlayMusicSound(sndRideOfTheValkyries) -- Replace the background music the Ride of the Valkyries
    20 </code>
    19 </code>
    21 
    20 
    22 === `StopMusicSound(soundId)` (0.9.25) ===
    21 == `StopMusicSound(soundId)` (0.9.25) ==
    23 Stops the specified “music sound” (if it was still playing) and resumes the main background music.
    22 Stops the specified “music sound” (if it was still playing) and resumes the main background music.
    24 
    23 
    25 === `SetSoundMask(soundId, isMasked)` (0.9.24) ===
    24 == `SetSoundMask(soundId, isMasked)` (0.9.24) ==
    26 Disables a given sound (including taunts) from being played by the engine. `soundId` is a valid sound ID on [Sounds] or [Taunts]. `isMasked` is a boolean. If `true`, the sound will not be played by the engine anymore. If `false`, playing this sound is allowed again.
    25 Disables a given sound (including taunts) from being played by the engine. `soundId` is a valid sound ID on [Sounds] or [Taunts]. `isMasked` is a boolean. If `true`, the sound will not be played by the engine anymore. If `false`, playing this sound is allowed again.
    27 
    26 
    28 Sounds played by the Lua function `PlaySound` will always work, however, and ignore the sound mask.
    27 Sounds played by the Lua function `PlaySound` will always work, however, and ignore the sound mask.
    29 
    28 
    30 Note: Due to the way the voices work internally in Hedgewars, if you want to play a masked voice, you have to set `instaVoice` to `true` when you call `PlaySound`. Otherwise, it won't work.
    29 Note: Due to the way the voices work internally in Hedgewars, if you want to play a masked voice, you have to set `instaVoice` to `true` when you call `PlaySound`. Otherwise, it won't work.