Attention! It is not info about my project, it's a backup of my article from Moddb!
This tutorial is for those who are a bit versed in scripts. At the end of this tutorial, there are examples of writing functions. This is for those who have not used them before. - IDL
Author of this tutorial - IDL
Also sorry, if my English is bad.
This tutorial is for those who are a bit versed in scripts. At the end of this tutorial, there are examples of writing functions. This is for those who have not used them before. - IDL
Functions
for load sound.
Functions:
- Sound:LoadSound(sound,flags);
- Sound:Load3DSound(sound, arg2, arg3, arg4, arg5);
- Sound:LoadStreamSound(sound,flags);
Arguments:
- sound - path to sound, flags - some settings for sound (optional).
- sound - path to sound, arg2 - some settings for sound (number or flag), arg3, arg4, arg5 - some number.
- sound - path to sound, flags - some settings for sound (optional).
Functions
for play sound.
Functions:
- Sound:PlaySound(sound);
- Sound:StopSound(sound);
Arguments:
- sound - loaded sound.
- sound - loaded sound.
Functions for editing sound.
Functions:
- Sound:SetSoundVolume(sound,volume);
- Sound:SetSoundPitching(sound, pitch);
- Sound:SetGroupScale(flag1, flag2);
- Sound:SetMinMaxDistance(sound, min, max);
- Sound:SetSoundLoop(sound, loop);
- Sound:AddToScaleGroup(sound, flag);
- Sound:SetSoundFrequency(sound, frequency);
- Sound:SetSoundProperties(sound,properties);
- Sound:SetSoundPosition(sound,position);
- Sound:SetDirectionalAttenuation(position, angles, fov);
- Sound:RemoveFromScaleGroup(sound, flag);
Arguments:
- sound - loaded sound, volume - some number from 0 to 255.
- sound - loaded sound, pitch - some number.
- flag1 - some flag, flag2 - some flag or number.
- sound - loaded sound, min - minimum radius of sound, max - maximum radius of sound.
- sound - loaded sound, loop - number.
- sound - loaded sound, flag - some flag.
- sound - loaded sound, frequency - some number.
- sound - loaded sound, properties - some properties (like fade).
- sound - loaded sound, position - some position.
- position - some position., angles - some angles, fov - field of vision.
- sound - loaded sound, flag - some flag.
Functions
for get some information about sound.
Functions:
- Sound:IsPlaying(sound);
Arguments:
- sound - loaded sound.
Functions for music system.
Functions:
- Sound:AddMusicMoodEvent(mood, timeout);
- Sound:SetDefaultMusicMood(mood);
- Sound:SetMusicMood(mood);
- Sound:SetMusicTheme(theme);
- Sound:ResetMusicThemeOverride();
- Sound:IsInMusicMood(mood);
Arguments:
- mood - name of mood, timeout - itself timeout (in seconds).
- mood - name of mood.
- mood - name of mood.
- theme - name of theme.
- ... (no arguments)
- mood - name of mood.
Functions for EAX system.
Functions:
- Sound:SetEaxEnvironment(eax,flags);
Arguments:
- eax - name of EAX effect, flags - some flags.
Some flags
for sounds.
Flags:
- SOUND_RADIUS
- SOUND_OCCLUSION
- SOUND_UNSCALABLE
- SOUND_RELATIVE
- SOUND_NO_SW_ATTENUATION
- SOUND_MUSIC
- SOUNDSCALE_UNDERWATER
- SOUNDSCALE_MISSIONHINT
- SOUND_VOLUMESCALEMISSIONHINT
- SOUNDSCALE_DEAFNESS
- SOUND_INDOOR
- SOUND_OUTDOOR
- SOUND_LOOP
Some music
moods for music system.
- Sneaking
- Combat
- Suspense
- NearSuspense
- Alert
- Victory
- Vehicle
- Observe
Examples
(starting with the fourth point, sounds must be loaded).
- local snd = Sound:LoadSound("sounds/player/water/swim2.wav"); - loading sound using path in 2D space (few formats work like "wav", "mp3").
- local snd = Sound:Load3DSound("sounds/player/water/WaterSplash.wav", SOUND_RADIUS, 160, 3, 50); - loading sound using path and optional properties in 3D space (few formats work like "wav").
- local snd = Sound:LoadStreamSound("sounds/player/water/swim2.wav",SOUND_INDOOR); - loading sound using path in 2D space (many formats work like "ogg", "wav", "mp3").
- Sound:PlaySound(self.SwimSound); - play loaded sound.
- Sound:StopSound(self.SwimSound); - stop playing loaded sound.
- Sound:SetSoundVolume(self.SwimSound,70); - set volume from 255 (by default) to 70.
- Sound:SetSoundPitching(CurrSound, 100); - set pitch to 100.
- Sound:SetGroupScale(SOUNDSCALE_DEAFNESS, 1); - all sounds other than this will not be heard.
- Sound:SetMinMaxDistance(CurSnd, .2, 200); - set minimum radius of sound to 0.2 and set maximum radius of sound to 200 in 3D space.
- Sound:SetSoundLoop(self.SwimSound, 1); - set loop mode for this sound.
- Sound:AddToScaleGroup(self.Sounds[i].Sound, SOUNDSCALE_UNDERWATER); - set for this sound flag SOUNDSCALE_UNDERWATER.
- Sound:SetSoundFrequency(self.LastPhysicsSounds.Roll, Volume*400+800); - set frequency for this sound.
- Sound:SetSoundProperties(self.sound,self.Properties.fFadeValue); - set fade effect for this sound in 3D space.
- Sound:SetSoundPosition(self.sndBreathIn,System:GetViewCameraPos()); - set position for this sound in 3D space (in this case I get the position of player 's camera).
- Sound:SetDirectionalAttenuation(_localplayer:GetPos(), _localplayer:GetAngles(), Game:GetCameraFov()); - set directional attenuation (this effect used for binocular).
- Sound:RemoveFromScaleGroup(self.EarRinging, SOUNDSCALE_DEAFNESS); - make a default sound.
- local getsnd = Sound:IsPlaying(sound); - check this sound for load.
- Sound:AddMusicMoodEvent("Sneaking", 1); - set time out for mood "Sneaking" to 1.
- Sound:SetDefaultMusicMood("Sneaking"); - set default music mood to Sneaking.
- Sound:SetMusicMood("Sneaking"); - change current music mood to Sneaking.
- Sound:SetMusicTheme("Forest"); - set music theme to "Forest".
- Sound:ResetMusicThemeOverride(); - unused function for vehicles.
- local mood = Sound:IsInMusicMood("Combat"); - mood "Combat" is playing?
- Sound:SetEaxEnvironment("Cave" ,0); - set EAX environment to OFF mode (default).
Author of this tutorial - IDL
Also sorry, if my English is bad.
No comments:
Post a Comment