Page 1 of 2
[Solved] How do I define sounds?
Posted: Tue Oct 21, 2014 10:36 pm
by KadoDragon
I have hud messages set up, but I want a non-looping sound to play a narration for the hud messages. I know there is a Sound entity, but I need to know how to define custom sound effects. I assume it is similar to defining custom ambient tracks.
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 12:08 am
by Jgwman
Go in your mod_assets/scripts/sounds.lua and define one. It can then be referenced from other lua files or in-editor script. I think it's very similar to defining one in Grimrock 1. Put the sound file in the mod_assets/sounds folder
Code: Select all
defineSound{…}
Defines a new sound or replaces an existing sound definition. The samples used need to be 16bit 44100Hz .wav-files. The function takes the following named parameters:
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.
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 12:22 am
by KadoDragon
Jgwman wrote:Go in your mod_assets/scripts/sounds.lua and define one. It can then be referenced from other lua files or in-editor script. I think it's very similar to defining one in Grimrock 1. Put the sound file in the mod_assets/sounds folder
Code: Select all
defineSound{…}
Defines a new sound or replaces an existing sound definition. The samples used need to be 16bit 44100Hz .wav-files. The function takes the following named parameters:
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.
Thank you for your response. I did all of that. I tried to go to test play and got this error.
Here is what I put into Sounds.lua, did I do it correctly?
Code: Select all
defineSound{
name = "Narration001",
filename = "mod_assets/sounds/Narr_01.wav",
loop = false,
volume = 1.00,
minDistance = 1000,
maxDistance = 1000,
}
Note: I put 1000 min and max distance so that you could hear it no matter where you moved. That may be what my problem is but I kind of doubt it. Is there any other way to make it so that it plays max volume no matter where you stand?
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 1:09 am
by Skuggasveinn
The error "Trying to play a non-mono 3D sound" is often spot on.
The wav file you need to use has to be mono as well as 16bit 44,1Khz
Skuggasveinn.
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 1:22 am
by KadoDragon
Skuggasveinn wrote:The error "Trying to play a non-mono 3D sound" is often spot on.
The wav file you need to use has to be mono as well as 16bit 44,1Khz
Skuggasveinn.
It is though.
EDIT:
This is the file I am using. Check it out if you must. It is 16 bit Mono Wav at 44,1khz
Edit 2: I found out that when trying to play sounds that came with the game, it either makes no sound or gives me the same error.
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 1:45 am
by Skuggasveinn
strange, I downloaded your file and it plays fine inside my editor
so there is nothing wrong with your file (I even used your code to be 100% sure)
Where is tech-support when you need them ?

(I'm all willing to help, just don't have clue what's happening here)
Skuggasveinn.
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 1:45 am
by Jgwman
How is it that you are attempting to play the sound, and when?
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 2:27 am
by KadoDragon
Jgwman wrote:How is it that you are attempting to play the sound, and when?
The way I have it set up is that where you start there is a treasure chest with a note inside of it. Once you take out that note, it fires off two triggers. A script entity to display a hud message and then a sound entity to play the sound file. Like this
EDIT: OKAY! Hold up. It is apparently working now... I have no idea what happened. I didn't change anything. But now I have another problem. The sound triggers right when the map loads and wont trigger after I remove the note from the chest.
EDIT 2: OKAY! ONCE MORE! I got it to work... Turns out that just reloading your dungeon in the editor doesn't update sound files. I had to close the editor completely, open it, then reload my mod. The sound file wasn't mono at first, and when I made that change the change didn't take in the editor, even after choosing reload. So the editor still thought it was stereo. On top of that, in order to not get the sound to play right away, all I had to do was in the sound entity, uncheck the box labeled sound. So much fiddling. This editor is the most simple, yet most finicky editor I have ever used. Consider this problem solved.
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 6:09 am
by Mysterious
Good idea there mate, but the problem is if the player puts the Item back into the chest the Script will activate again etc...
Re: How do I define sounds?
Posted: Wed Oct 22, 2014 6:38 am
by SnowyOwl47
Mysterious wrote:Good idea there mate, but the problem is if the player puts the Item back into the chest the Script will activate again etc...
Easy fix have a script use the if method so something like
Code: Select all
musicplayed = false
function music()
if musicplayed == false then
playSound("")
musicplayed = true
end
end