Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSameGroup query

psimagus Hax
Registered User
Join date: 3 Jul 2007
Posts: 73
05-13-2008 15:03
Hi,

I'm having trouble getting my head around the (llSameGroup(llDetectedKey(0)) in a mailbox script I'm trying to write, and I'm sure I must just be missing something simple again. I consulted the example on the wiki, and tried to do the same, but with a listen instead of touch_start. The listen's working (if I disable the if/else that checks the group, the message entered on channel 9 is hovertexted and emailed ok,) but llSameGroup(llDetectedKey(0)) seems to always return FALSE, even when I am definitely wearing the same group tag as the object is set to.

Am I just fundamentally misunderstanding how to implement the function? Or have I failed to typecast a variable properly somewhere? (that still confuses me sometimes.)

Any more expert advice would be very gratefully received.




integer position;
string avname;
string message;
string EMAIL = "whatever@somewhere.com";

default
{
touch_start(integer total_number)
{
}

state_entry()
{
llSetText("Waiting for message", <1.0,1.0,1.0>, 0.5);
llListen( 9, "", NULL_KEY, "" );
}

listen( integer channel, string name, key id, string message )
{
if (channel == 9) {

if(llSameGroup(llDetectedKey(0)))
{
string messageName = llKey2Name(id);
llSay( 0, "Thankyou, " + (string)messageName + ", your message has been sent.";);
llSetText((string)message, <1.0,1.0,1.0>, 1.0); //TEMP TO TEST
string mailbody = message + " (" + messageName + ";)";
llEmail (EMAIL, "New message recorded", (string)mailbody);
}

else
{
llSay(0, "Wrong active group! If you belong to the group this object is set to, please activate your group tag. Otherwise please join the group.";);
}
}
}
}
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
05-13-2008 15:32
detectedkey doesn't work in a listen(), use the id recieved in the listen event instead and see if that works.

ie:
"llDetectedKey(0)" should be replaced with "id"

Also the check for channel == 9 isn't needed, that is the only channel you are listening to.

You shoul d also be able to replace the 'llKey2Name(id)' with 'name' as the name is recieved in the listen event also.
Shyan Graves
Registered User
Join date: 10 Feb 2007
Posts: 52
05-13-2008 15:44
Agree to Shadow :)

see also

Regards
Shyan
psimagus Hax
Registered User
Join date: 3 Jul 2007
Posts: 73
05-13-2008 16:01
From: Shadow Subagja
detectedkey doesn't work in a listen(), use the id recieved in the listen event instead and see if that works.

ie:
"llDetectedKey(0)" should be replaced with "id"


Aaah! Many thanks - that works a treat now :)
I didn't see any mention of that in the wiki, but then again I'm not always sure what I'm looking for (or even at!) sometimes, since I still get out of my depth so easily.

From: Shadow Subagja
Also the check for channel == 9 isn't needed, that is the only channel you are listening to.

You shoul d also be able to replace the 'llKey2Name(id)' with 'name' as the name is recieved in the listen event also.


there'll be a configuration channel eventually too, but I left the other half of the code out of the posted example for the sake of clarity (and that still has its own pile of problems - but I like to figure them out by myself if I can, and I haven't exhausted those yet :))