trying to use listen in if then statement
|
Unmitigated Gall
Registered User
Join date: 16 Jun 2005
Posts: 24
|
10-23-2005 09:34
Hmmm... rookie scripter and trying to use a Listen in and if - then - else statement and it tells me I have a syntax error... hope this makes sense... Any guidance is greatly appreciated...
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
10-23-2005 09:41
Post the script! 
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
10-23-2005 09:46
If you're using a listen EVENT inside the statement, that won't work. If you're using the llListen function inside your if-then statement, then you're probably just missing something simple (usually it's a comma or a semi-colon).
Post the script, we'll fix it for you.
|
Unmitigated Gall
Registered User
Join date: 16 Jun 2005
Posts: 24
|
Kenn... u nailed it...
10-23-2005 11:16
my problem was exactly that... gotta rewrite now to place that out in the open
then have it test the dialog answer to determine what to do next..
Thanks yall..
|
Unmitigated Gall
Registered User
Join date: 16 Jun 2005
Posts: 24
|
Sorry one other dumb question about listens....
10-23-2005 11:19
Does that mean that every listen occurs the minute the script starts? So that if I wanna get input from the chat line, that it is always listening? I only want it to start if a certain fialog option is picked..
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
10-23-2005 11:50
It sounds like you are trying to set up the listen after the dialog option has been chosen. Dialog needs a listen event already running to understand which choice you made in the dialog. What you could do is, have the object use a touch event to turn on the listen, then dialog the avatar. The avatar could make the choice, then you could use a quick timer after the choice is made to remove the listen. Hope that helps.
|
Frosty Fox
Registered User
Join date: 28 Feb 2005
Posts: 18
|
10-23-2005 15:02
Hope This helps, integer channel = 1; integer Handle; Handle = llListen(channel, "", NULL_KEY, ""  ; // This makes a script start to lisen llListenControl(Handle, FALSE); // this stops the script lisening on the channel 
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
10-23-2005 18:12
Hmmm...yea...a Dialog box must have an active listen going in order to record the button push (a dialog button push makes the avatar "say" the name of the button on the declared listen channel. If there is no active listen event, there will be no response to a button push from the dialog). Cid's idea of the touch event to trigger a listen is great...
list buttonlist = [];
...
touch_start(integer number) { llListen(1, "", NULL_KEY, ""); llDialog(llDetectedKey(0), "Please Choose an Option", buttonlist, 1); }
listen(integer channel, string name, key id, string message) { handle = llListen(1, "", NULL_KEY, ""); llListenRemove(handle); if(message == "x") {
} }
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
10-24-2005 01:58
Fixed the script:
list buttonlist = []; integer handle;
...
default { touch_start(integer number) { handle = llListen(1, "", NULL_KEY, ""); llDialog(llDetectedKey(0), "Please Choose an Option", buttonlist, 1); } listen(integer channel, string name, key id, string message) { llListenRemove(handle); if(message == "x") { } } }
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
10-24-2005 07:50
Can I suggest adding to the script a timer call just after you set the dialog set to some suitable time (I usually use a minute) to turn the listener off as well (assuming you're not using the timer for something else).
Then when the person crashes, changes their mind etc. (or hits ignore) you turn the listener off eventually. You can then put a llSetTimerEvent(0.0); line just after the listen removes if appropriate, and you tidy up more nicely again.
|
JP Burleigh
Registered User
Join date: 15 Oct 2005
Posts: 11
|
10-24-2005 08:22
It is also my understanding that the listner goes away when you change state. In some of my scripts I have leveraged this as I transition my objects from "listening" mode to "inactive" mode. I have found it more manageable to control this thru state rather than just using a timer within a single state. Of course, it is common to transition state by using the timer  - JP
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
10-24-2005 09:36
Yes, listeners should go away with a change of state. So should other things, but timers for one don't always, so I'm a bit careful.
I also went through a phase of using states a lot. Now I use them rarely. I do use them but don't often find things that demand their use. That might just reflect what I'm scripting of course.
|