Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Wrapping my arms around keys...

Denrael Leandros
90 Degrees From Everythin
Join date: 21 May 2005
Posts: 103
07-29-2005 09:00
I'm playing with scripts and trying to understand a few things.

On a touch event, it looks like llDetectedKey is how I figure out who touched the prim. Is this true?

On the llListen function, the doc says I can leave ID blank, but I dont see a way to do that without getting an error. Can someone point me in the right direction? Essentially I'm trying to catch an event where anyone can touch something, present a dialog box to that person, and then listen for the answer and take an action.

I have it working for me, but I'm not sure if it's the best way (see below):

integer CHANNEL = 24601; // Default Listen Channel
default
{
state_entry() {
llListen(CHANNEL, "", llDetectedKey(0), "";); // listen for the dialog answer
}

touch_start(integer total_number) {
llDialog(llDetectedKey(0), "This picture will display any of the following Zodiac signs. Please select one.", ["Scorpio", "Taurus", "Virgo", "Libra", "Pisces", "Sagittarius", "Capricorn", "Gemini", "Leo", "Aquarius", "Aries", "Cancer"], CHANNEL);

}

listen(integer channel, string name, key id, string message) {
llSetTexture(message, 2);
llSay(0, message);
}
}
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
07-29-2005 09:08
The llDetected*() functions only work in certain events, like the touch events and the sensor event.

For what you're doing, I reccomend the following:
CODE
integer lhan; // Listen handler
integer CHANNEL = 24601;

default
{
touch_start(integer i)
{
llListenRemove(lhan); // just to be sure.
lhan = llListen(CHANNEL, "", llDetectedKey(0), ""); // Start listening for the reply
llDialog(llDetectedKey(0), "This picture will display any of the following Zodiac signs. Please select one.", ["Scorpio", "Taurus", "Virgo", "Libra", "Pisces", "Sagittarius", "Capricorn", "Gemini", "Leo", "Aquarius", "Aries", "Cancer"], CHANNEL); // Dialog pop-up.
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(lhan); // remove the listen and it's filter.
llSetTexture(message, 2);
llSay(0, message);
}
}


EDIT: Oh, and a "blank" key can be had with the constant NULL_KEY, as in llListen(90, "", NULL_KEY, "";);
_____________________
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
07-29-2005 09:12
and to answer your other question about leaving the key blank, you still need to put something in that spot to prevent an error, so a blank key is referenced as NULL_KEY
Denrael Leandros
90 Degrees From Everythin
Join date: 21 May 2005
Posts: 103
07-29-2005 10:27
So if I understand what you're doing, youre using the listener handle to insure that the object isn't listening when it's not supposed to?
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
07-29-2005 10:47
Yep. Good for avoiding lag, good for avoiding accidental triggering.
_____________________