Page 1 of 1

can anyone help with sound script?

Posted: Sun May 26, 2013 5:54 pm
by MYNAMEIS
i need to play sound, called "horror" in this place.
I already done all in the file "sounds.lua".
So i only need to do something with script.
Can anyone help me? :3

i used that script:
playSoundAt(sound, level, x, y), so i wrote this:

function playSound()
playSoundAt(horror, 10, 29, 16)
end

and pc says me:

bad argument #1 to 'playSoundAt' (string expected, got nil)

what i supposed to do? where is error?

Image

Re: can anyone help with sound script?

Posted: Sun May 26, 2013 7:33 pm
by JohnWordsworth
Hi MYNAMEIS,

Sounds are one of those things that can be a little bit fiddly. Luckily, this looks like a nice easy fix. As the error states: "bad argument #1 to 'playSoundAt' (string expected, got nil)"

The function playSoundAt requires the name of the sound effect definition as the first parameter. This should be a "string" variable, what you have provided is a variable named horror, which presumably doesn't exist and is therefore nil. The solution is just to add quotes:

playSoundAt("horror", 10, 29, 16);

Hope your mod is going well!

Re: can anyone help with sound script?

Posted: Mon May 27, 2013 1:23 am
by Komag
You also might consider naming the function something else just to be clear, because playSound is already a standard command

Re: can anyone help with sound script?

Posted: Mon May 27, 2013 3:31 am
by Neikun
I agree with Komag,
try a function more like playHorror

Also, can we get a look at your sounds.lua?

Re: can anyone help with sound script?

Posted: Mon May 27, 2013 2:48 pm
by MYNAMEIS
thanks! :D