Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
11-14-2004 14:03
Hi, I have an object with 4 seats, all linked together... And I want to make one of 4 corresponding objects rez when I sit on one of the seats...(Sit on seat 1, object 1 rez' es, get off seat 1 and it derez'es, sit on seat 2 obj 2 rez'es, ect...) However, using the standard, "check and see if CHANGED_LINK", and then "llAvatarOnSitTarget()" to get the key of an avatar gives me the result that when person A sits on seat A, person B's object says, "Oh, changed link, and there's someone sitting on me!" and person B is rez'ed a second copy of the object... And then when someone stands up, it's supposed to kill their corresponding object... which it does, but it hits the CHANGED_LINK call in each other object and if someone is sitting on other seats, rez'es another copy for them..
Ok, before I ramble out of control, to paraphrase, I guess what I'm asking is, is there any other commands I'm missing that might help me out here? Like a "LOCAL_CHANGED_LINK"... I get that when you sit on something, it calls CHANGED_LINK and when you stand up, it calls it again... because you're just linking and unlinking your AV to the seat... And since I need to keep the seats linked, I'm trying to weasel my way out of some complicated "administrative script" that says, "Ok, changed link, previously we had 3 people sitting, now we have 4, lemme check which one has changed, lemme only rez the object for the 4th person who just sat, now we have 3 people sitting again, re-check who was previously sitting to find who got up, just un-rez their object, blah, blah, blah..."
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
11-14-2004 14:23
You need to add logic to your script so that it knows if someone is already sitting on the prim. I would suggest having two states... "empty", and "sitting". In your sitting state, you won't give the object when llAvatarOnSitTarget() returns a key, because you'll know that its already been given. Try something like this... state default { state_entry() { state empty; } }
state empty { changed( integer change ) { if ( llAvatarOnSitTarget() != NULL_KEY ) { // code to give your object goes here state sitting; } } }
state sitting { changed( integer change ) { if ( llAvatarOnSitTarget() == NULL_KEY ) { state empty; } } }
_____________________
"Free your mind, and your ass will follow" - George Clinton
|
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
|
11-14-2004 17:00
this is the code I typically use. I haven't expernced any trouble with it. But I won't claim it's perfect. //global variables key userID = NULL_KEY ; //global settings vector sitVector = <0.0,0.0,0.00001> ; rotation sitRotation = ZERO_ROTATION ; string sitText = "Relax" ;
// sit detection setUp ( key sitID) { userID = sitID; // on sit code here llSay( 0, "sit detected: " + (string)sitID ); }
shutDown () { // on stand code here llSay( 0, "stood detected: " + (string)sitID ); userID = NULL_KEY; }
sitDetect ( key newKey, key currenKey ) { if ( newKey != NULL_KEY && currenKey == NULL_KEY ) { setUp ( newKey ); } else if ( newKey == NULL_KEY && currenKey != NULL_KEY ) { shutDown (); } }
//States and triggers default { state_entry() { llSitTarget( sitVector, sitRotation ); llSetSitText( sitText ); } changed( integer change ) { if ( change == CHANGED_LINK ) { sitDetect( llAvatarOnSitTarget(), userID ); } } }
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
11-30-2004 09:47
Thank you both! Like most other things in my life, I posted this question and then promptly got sidetracked for about a month, came back and solved it. Much appreciated!
|