Can someone help me with the 'playSound()' command? I have used this in Grimrock 1 with predefined sounds and it works just fine. But when I tried to use it with a custom sound it didn't work.
I created a short sound and saved it as a *.wav file in my dungeon's 'mod_assets\sounds' folder
I reloaded the dungeon hoping the engine would pick up the mod assets.
I created a script using...
plalySound("mod_assets/sounds/filename.wav")
But every time the script runs I get a message saying: Warning! no such sample: filename.wav
Can anyone tell me the proper procedure and script for playing a custom sound in Grimrock 1?
playSound()
Re: playSound()
The engine doesn't recognizes sounds from just being in the sound folder. First you have to define your sound. Like this:
In the playSound command you have to use the given name of the sound:
Sidenote: It was the same in Grimrock 1...
Code: Select all
defineSound{
name = "wall_breaking",
filename = "mod_assets/sounds/sx_wallbreaking.wav",
loop = false,
volume = 3.00,
minDistance = 2,
maxDistance = 2,
}Code: Select all
playSound("wall_breaking")Re: playSound()
Thank you. It works great. But, a few questions about the settings...
I assume the 'loop = false' setting is to play the sound once. However, if set to 'true', how then would you stop the sound after a few repetitions? Is there a stop command or would you have to define another sound with loop set to false and then call that?
Why a volume of 3? How does that correspond to the volume you set in 'Options'? And what are the possible minimum and maximum values you can use? Is 3 sort of a standard or mid-range value?
What about the distance? If you set 'maxDistance' to 5 does that mean you could here the sound from 5 tiles away from where it was called? If so, why would you have to bother with a 'minDistance'?
I don't mean to press. I know you guys are probably very busy answering questions but it bugs the heck out of me not to know exactly what I am doing. Again, thanks for the help.
I assume the 'loop = false' setting is to play the sound once. However, if set to 'true', how then would you stop the sound after a few repetitions? Is there a stop command or would you have to define another sound with loop set to false and then call that?
Why a volume of 3? How does that correspond to the volume you set in 'Options'? And what are the possible minimum and maximum values you can use? Is 3 sort of a standard or mid-range value?
What about the distance? If you set 'maxDistance' to 5 does that mean you could here the sound from 5 tiles away from where it was called? If so, why would you have to bother with a 'minDistance'?
I don't mean to press. I know you guys are probably very busy answering questions but it bugs the heck out of me not to know exactly what I am doing. Again, thanks for the help.
Re: playSound()
playSound() and playSoundAt() are not useful for looping sounds. Looping sounds are for things like SoundComponent that can be stopped.RayB wrote:Thank you. It works great. But, a few questions about the settings...
I assume the 'loop = false' setting is to play the sound once. However, if set to 'true', how then would you stop the sound after a few repetitions? Is there a stop command or would you have to define another sound with loop set to false and then call that?
Multiplier for the volume of the sound. Using a volume greater than 1 is generally stupid (if your sound is normal I'm pretty sure you are going to cause clipping for people with sound volume at max, and if your sound isn't normal then you're not taking proper advantage of full 16-bit resolution and should re-make your sound from the source material so that it IS normal).RayB wrote:Why a volume of 3? How does that correspond to the volume you set in 'Options'? And what are the possible minimum and maximum values you can use? Is 3 sort of a standard or mid-range value?
minDistance is the distance at which volume falloff begins (volume is 1 before it). maxDistance is the distance at which volume falloff ends (volume is 0 after it).RayB wrote:What about the distance? If you set 'maxDistance' to 5 does that mean you could here the sound from 5 tiles away from where it was called? If so, why would you have to bother with a 'minDistance'?
Have you considered reading the scripting references? I think you'd know a lot more about what you were doing if you did! In particular, all your questions here are answered in it!RayB wrote:I don't mean to press. I know you guys are probably very busy answering questions but it bugs the heck out of me not to know exactly what I am doing. Again, thanks for the help.
https://github.com/JKos/log2doc/wiki
http://www.grimrock.net/modding/scripting-reference/
http://www.grimrock.net/modding/scripti ... dComponent
defineSound(desc)
Defines a new sound or replaces an existing sound definition. The samples used need to be 16bit 44100Hz .wav-files. desc is a table with the following fields:
name: the name of the sound to define or replace.
filename: the filename of the sample in wave format. The filename must be a valid asset reference ending with “.wav”. Optionally the filename may be a table containing multiple filenames for random sound variations.
loop: a boolean which turns on and off looping.
volume: a number between 0 and 1 which controls the amplitude of the sound.
minDistance: the minimum distance in squares for sound falloff. The sound plays at max volume if it is closer than min distance to the listener.
maxDistance: the maximum distance in squares for sound falloff. The sound is not audible after max distance.
playSound(sound)
Plays a sound effect. sound must be a name of a built-in or custom sound effect.
playSoundAt(sound, level, x, y)
Plays a sound effect at given position. sound must be a name of a built-in or custom sound effect.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.