Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

dected if seated

Attica Bekkers
Registered User
Join date: 12 Apr 2007
Posts: 28
10-14-2008 22:43
I want to detect if an avatar is seated, and there is one more than seat, is there away to detect if the key is part of the link set? as away of detecting sit target when there are quite a few poseballs?

Id usually use if (llDetectedkey(0) == llAvatarOnSitTarget

Im thinking if the detected key is link number 10 or 11 ona nine prim object means they are seated.. but i just cant work it out.
Please help
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-15-2008 01:57
Just loop through each link in the linkset from 1 through llGetNumberOfPrims(), testing llGetLinkKey() until you find the match.

But it's not quite clear what you're matching with that link: whence did this llDetectedKey(0) arise? Something like this would work if, for example, this is in a touch_start() handler and the objective is to see whether the agent who touched is also one of the seated agents. But if this bit of code is triggered by a CHANGED_LINK event when some agent sits or stands, there is no llDetectedKey().
Attica Bekkers
Registered User
Join date: 12 Apr 2007
Posts: 28
10-15-2008 04:04
thanks!
yes it is a touch_start().

I just wanted to stop people who are not seated getting a dialog menu. A dialog on sit would be kind of annyoing after multpile uses, so I want to make it on touch.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-15-2008 04:56
if you know the number of prims in the object and it doesn't change, any number of prims above that will be seated av's... and you'll want to start testing at the link number that equals the number of prims (becuase they number from 0) up to the total count of links - 1, assuming you need to actually get the seated av's keys... otherwise if you just need to know if or how many avs are seated

CODE

//-- for a single prim box gPrimCount = 1
integer gPrimCount = 1;
integer gAvCount;

default(){
changed ( integer vBitChanges ){
if ( CHANGED_LINK & vBitChanges ){
gAvCount = llGetNumberOfPrims() - gPrimCount;
llSay (0, "there are " + (string)gAvCount + " avs sitting on me");
if (gAvCount){ //-- greater than 0
llSay( 0, "Their names are...." );
integer vAvNum;
for ( vAvNum = gPrimCount -1, vAvNum < gPrimCount + vAvCount, ++vAvNum){
llSay( 0, llKey2Name( llGetLinkKey( vAvNum ) );
}
}
}
}
}


note: not checked for syntax, but that should give you the basis
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-15-2008 08:01
I recently (last 6 months?) that llGetNumberOfPrims and llGetObjectPrimCount return different values, the latter does not count avatars.

http://wiki.secondlife.com/wiki/llGetNumberOfPrims

CODE

integer GetNumberOfAgents()
{//count avatars
return llGetNumberOfPrims() - llGetObjectPrimCount(llGetKey());
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Attica Bekkers
Registered User
Join date: 12 Apr 2007
Posts: 28
10-20-2008 20:47
thankyou so much for this:)
very helpful