Problem with direct call to Sound function

Posted by Seriley on Sat 29 Jan 2011 08:10 PM — 9 posts, 37,729 views.

#0
I have a trigger that I would like to selectively produce a sound:

if StealthMode and not Fighting then
  Sound("C:\Program Files (x86)\MUSHclient\sounds\claves.wav")
end

I've used the full path here, but I also tried just "claves.wav" and verified that path as the default to the sounds directory using GetInfo (74).

I get the default activity sound, not the 'claves' sound.

I get this also when I enter '/Sound ("claves.wave")' on the command line (/ is the default lua escape)

If I use the built-in sound mechanism provided in the trigger dialog, it works fine. I get the correct sound.

I've tried lowering the sequence number of the trigger as a workaround suggested on the forum in 2006 and it did not help. If the poster meant I should make the trigger fire after all triggers, then I'm not able to do that as I have many triggers already at seq = 10000.

Any suggestions?
Amended on Sat 29 Jan 2011 08:12 PM by Seriley
USA #1
\ is a special character, so you need to either escape it as \\, or use the [[ ]] quotes where \ is just a normal character.

Sound([[C:\Program Files (x86)\MUSHclient\sounds\claves.wav]])
#2
Thanks, Twisol

When I do that, I now get the correct sound when I enter /Sound([[ .... ]]) from the command line.

I still don't get the correct sound when I make the script call in my trigger
USA #3
Can you please paste your trigger here?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
#4
<triggers>
<trigger
enabled="y"
group="Imperian_Tracking"
match="^You have recovered balance\.$"
name="balance_recovery__"
regexp="y"
send_to="12"
sequence="10000"
>
<send>if StealthMode and not Fighting then
Sound([[C:\Program Files (x86)\MUSHclient\sounds\claves.wav]])
end</send>
</trigger>
</triggers>
USA #5
It looks correct. Can you double-check that you don't have any other Sound() calls in other triggers that might be matching the line instead of this trigger?
#6
I have no other trigger on the pattern - You have recovered balance. I checked my plugin files also for that pattern.

If I just use the sound functionality provided in the dialogue, which would always play the sound on the match, the correct sound is played whenever the trigger matches.
Australia Forum Administrator #7
I am a bit nervous of backslashes in file names in send to script. It is easy to get the number wrong. How about:


if StealthMode and not Fighting then
  Sound( GetInfo (74) .. "claves.wav" )
end


That gets rid of them. GetInfo (74) is the default sound files directory, which is "sounds" under the MUSHclient.exe folder.
#8
That did the trick! It now works the way I want it too. Thanks, Nick and Twisol!