Jump to content

Using llAvatarOnSitTarget()


Artix Ruxton
 Share

You are about to reply to a thread that has been inactive for 4722 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Yeah I've been trying that but for some reason when a second avatar sits down and I try to llUnSit(llAvatarOnSitTarget()) it unsits the person that's already sitting down, not the person thats trying to sit down. Here's a code snippet:

key user = NULL_KEY;  // global variable

changed(integer change) {       

if (change & CHANGED_LINK)       {           

key sitter = llAvatarOnSitTarget();                       

if(sitter)             {               

if(user == NULL_KEY)                {                   

user = sitter;                   

llRequestPermissions(user, PERMISSION_TRIGGER_ANIMATION);                   

llStartAnimation("sleep");                   

 }               

else if(sitter != user)                {                   

Say(llKey2Name(user)+" is resting here.");                   

llUnSit(user);               

}           

}           

else           {              

llResetScript();           

}     

  }   

Link to comment
Share on other sites

sorry type in that, should read llUnSit(sitter); 

Also, I was thinking of recursing through the set of linked prims and finding the second person to sit down's UUID and compare that to the llAvatarOnSitTarget(), because it seems like only the first person to sit down on the prim registers as being on the Sit Target

 

Link to comment
Share on other sites

That's right.  You can only have one person on a sit target at a time.  And a prim can only have one sit target.  That doesn't mean that a second person can't sit.  If the prim is large enough to have space for a second (or third....) person, that person can sit anywhere.  llUnSit only applies to the person who is on the actual sit target, though. 

Link to comment
Share on other sites

I haven't tried this, but it might be worth seeing if you can rez a second phantom version of the seat just barely above the actual one as soon as person A sits down.  Then, put a sit target in that seat, along with a short script that automatically unseats anyone who sits on it. Kill that phony seat as soon as person A stands up.

  • Like 1
Link to comment
Share on other sites

I've not tested it, but something on these lines might do it.    The idea is that llGetObjectPrimCount(llGetKey()) will return the number of prims in the linkset -- assuming it's in the root prim, otherwise I guess you need llGetObjectPrimCount(llGetLinkKey(1)) -- while llGetNumberOfPrims() is prims plus seated avatars.

Worth a try, anyway.

 

key av;
 default {
 state_entry() {
 llSitTarget(<0.0,0.0,0.5>,ZERO_ROTATION);
}
 changed(integer change) {
 if(change & CHANGED_LINK){
 av = llAvatarOnSitTarget();
 if(av!=NULL_KEY){
if(llGetNumberOfPrims()>(llGetObjectPrimCount(llGetKey()) + 1)){
 llUnSit(av);
 }
}
}
}
}

 ETA -- dunno what's happening with the editor

  • Like 1
Link to comment
Share on other sites

Hey!  I just tried it.  It DOES work, beautifully.  Here's the script for a real seat....

default { state_entry() { llSitTarget(<0.85,0.0,0.8>,ZERO_ROTATION); } changed(integer change) { if(change & CHANGED_LINK) { integer CHAN = (integer)("0xF" + llGetSubString(llGetKey(),0,6)); key AV = llAvatarOnSitTarget(); if (AV) { llRezAtRoot("NewSeat",llGetPos() + <0.0,0.0,0.02>, ZERO_VECTOR,ZERO_ROTATION,CHAN); } else { llWhisper(CHAN,"Get Lost!"); } } } } 

 

 

And here's a script to put in an identical phony seat, which you thent put into the real seat....

default { on_rez(integer startup) { llListen(startup,"","",""); llSitTarget(<0.0,0.0,0.1>, ZERO_ROTATION); } changed (integer change) { if(change & CHANGED_LINK) { if(llAvatarOnSitTarget()) { llUnSit(llAvatarOnSitTarget()); } } } listen(integer channel, string name, key id, string msg) { if (msg == "Get Lost!") { llDie(); } } } 

 ETA:  WHAT IS GOING ON with this stupid editor???  This looks really dumb, but the scripts do work.  I just can't get them to format correctly here.  Cut and paste them into your own editor, though... :smileymad:

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4722 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...