Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Not Sure What To Do Next

Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
10-26-2007 08:29
I'm trying to make a little joke attachment that specifies the play of one of two soundwavs in the attachment's inventory.

CODE


string sound ="sound2.wav";

default
{
state_entry()
{
llLoopSound("sound1.wav", 0);
llListen(1, "", "","quiet");
llListen(1, "", "","makenoise");
llListen(0, "", "", "wordX");
}

listen(integer channel, string name, key id, string m)
{
if (m == "quiet")
{
llStopSound();
}
if (m == "makenoise");
{
llResetScript();
}
if (m == "wordX");
{
llStopSound();
llPlaySound(sound,1);
}

}
}



wordX above is a specific trigger word heard in chat. What I'm wanting to know is, how can I specify this so that if the Listen hears any phrase plus the trigger word, it will respond. At present only if the trigger word is spoken in isolation, will sound1.wav stop and sound2.wav play

Also, I think maybe this is kind of laggy with the listen and stuff. How can I make that better?
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
10-26-2007 08:49
oops, I made a little mistake above.. sound1.wav is playing at 1 up there, not 0
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
10-26-2007 08:50
if (llSubStringIndex(m, "xword";) != -1)

But this will also require a completely 'open' listen: llListen(0, "", "", "";);

...so, even more laggy! :D
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
10-26-2007 09:04
thank you so much Pale!
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
10-26-2007 09:40
Why do you reset the script when you hear makenoise? It looks ot me like all you need to do is to stop the current sound and then loopsound sound1.

Also, do you need to listen to *everybody*? Maybe you could listen to specific people.
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
10-26-2007 09:47
From: Lee Ponzu
Why do you reset the script when you hear makenoise? It looks ot me like all you need to do is to stop the current sound and then loopsound sound1.

Also, do you need to listen to *everybody*? Maybe you could listen to specific people.


yes, I could change the reset thing.
For this joke, yes it's needed that anybody within chat distance be able to trigger it.
Fortunately,it's an attachment that wont' get a great deal of wear year round;)