Help with a voice on/off command please
|
|
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
|
08-05-2006 11:24
I've made a shower using a standard waterfall script that is in our Library. The problem I'm having is that the voice command for spray off and spray on doesn't seem to be responding. Maybe some body can point out what needs to be tweaked. Script is as follows: // Particle System 1.0 StartSteam() { Then there's a long section specifying the particle parameters, speed, size, alpha and all that stuff. then after the particles: } StartSpray () { } StopSpray() { llParticleSystem([]); } default { state_entry() { StartSteam(); } listen(integer channel, string name, key id, string message) { if (0 == llSubStringIndex(message, "spray on"  ) { StartSteam(); } else if (0 == llSubStringIndex(message, "spray off"  ) { StopSpray(); } } } So, basically, the voice command is not responding. The shower remains on and nothing I say is turning it off. Anybody know what is wrong with this? Thanks very much for your feedback!
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-05-2006 11:45
I realise you've parsed the script right down, but there's no llListen() line in what you've sent us. If that's not there in the original you're in trouble. Using the listen event (a bit like the sensor event) requires you to set the parameters that will fire it - for listening that's done via llListen - find out more on the wiki. If that's not the problem we'll need to see more of the script I'm afraid.
|
|
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
|
08-05-2006 12:43
Aside from the lack of llListen, your 'if' statement should match the listen parameters. if(message == ...)
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
08-05-2006 12:46
aye the integer 0 will never == "spray on"
|
|
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
|
08-05-2006 14:09
Thanks so much for replies..I'll look through the particle stuff to see if that Listen is there, I dont think it is though. Thanks for the pointer to the Wiki Listen thingy..I should be able to fix this from that!)
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-05-2006 17:33
From: Osgeld Barmy aye the integer 0 will never == "spray on" That's not what he was testing, I believe. Note the use of 'llSubStringIndex()'.
|
|
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
|
08-05-2006 23:27
From: Hewee Zetkin That's not what he was testing, I believe. Note the use of 'llSubStringIndex()'. But unless some vital pieces were stripped from the code before posting, that 0 is still completely useless... And, correct me if I'm wrong... an integer can't be used as a variable name anyway, due to the conflicts it would cause within scripts, so it becomes even more useless 
|
|
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
|
08-06-2006 02:42
From: Xixao Dannunzio But unless some vital pieces were stripped from the code before posting, that 0 is still completely useless... And, correct me if I'm wrong... an integer can't be used as a variable name anyway, due to the conflicts it would cause within scripts, so it becomes even more useless  You seem to be writing gibberish? http://secondlife.com/badgeo/wakka.php?wakka=llSubStringIndexNote that llSubStringIndex returns an integer, the index of the pattern in the source string. if (0 == llSubStringIndex(message, "spray on"))
if message is "spray on", then llSubStringIndex will return 0, so the code is effectively: if (0 == 0)
Which is true,...
|
|
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
|
08-06-2006 02:44
Ah, yes. I stand corrected 
|
|
Dellybean North
Registered User
Join date: 8 May 2006
Posts: 321
|
08-07-2006 08:28
Just a followup, thanks everyone for feedback.. got this on/off business working. Tweaked it from looking at a bling script as follows: key curOwner; // Particle System 1.0 Big long usual section determining charcter of the particles. } StartSpray () { } StopSpray() { llParticleSystem([]); } default { on_rez(integer start_param) { curOwner = llGetOwner(); } attach (key id) { curOwner = llGetOwner(); } state_entry() { llListen(1,"",curOwner,""  ; updateParticles(); } listen(integer channel,string name,key id,string message) { if(message == "spray"  { updateParticles(); } if(message == "sprayoff"  { llParticleSystem([]); } } }
|