problem with llSitTarget
|
|
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
|
03-11-2007 08:38
i have a problem with the scipt below. I use a prim with 6 different sit animations and everytime i go sit on it the script use at random a different animation with its own Positition and Rotation. The problem is that the script use the postition and Rotation from the previous animation and not the current position and rotation. does anyone know how i can solve this.
vector POSITION =<-1.15, 0.0, 0.1>; vector Rotdeg = <0,270,0>; string SitAnim; integer randomSit;
default { state_entry() { llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } changed(integer change) { if (change & CHANGED_LINK) { if (llAvatarOnSitTarget() != NULL_KEY) { llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); } else { integer perm=llGetPermissions(); if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(SitAnim)>0) llStopAnimation("sit"); llStopAnimation(SitAnim); SitAnim=""; } } } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { randomSit = (integer)llRound(llFrand (5)); if(randomSit == 0) { vector POSITION=<-1.15, 0, 0.1>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 1) { vector POSITION=<-1.15, 0, -0.6>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 2) { vector POSITION=<-0.95, 0, -0.28>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 3) { vector POSITION=<-1.07, 0, -0.4>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 4) { vector POSITION=<-1.45, 0, -0.4>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else { vector POSITION=<-1.07, 0.70, -0.4>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } SitAnim=llGetInventoryName(INVENTORY_ANIMATION,randomSit); llStopAnimation("sit"); llStopAnimation(SitAnim); llStartAnimation(SitAnim); llSay(0, (string)randomSit + ":" + SitAnim);
} } }
|
|
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
|
03-11-2007 08:43
Sorry but somehow i have posted this 3 times and don't know how to delete the other 2.
|
|
Saddeus Toll
Registered User
Join date: 16 Jan 2007
Posts: 12
|
03-11-2007 09:01
You should set up the sit position and the new animation when the previous person stands up (change & CHANGED_LINK && llAvatarOnSitTarget()==NULL_KEY) so that the new sit position and animation is ready for the nex person that sits down.
|
|
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
|
03-11-2007 11:06
i think i understand you wrong . i have changed it (see below) but this doen't work. vector POSITION =<-1.15, 0.0, 0.1>; vector Rotdeg = <0,270,0>;
string SitAnim; integer randomSit;
default { state_entry() { llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } on_rez(integer r) { llResetScript(); } changed(integer change) { if (change & CHANGED_LINK && llAvatarOnSitTarget()==NULL_KEY) { llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); randomSit = (integer)llRound(llFrand (5)); if(randomSit == 0) { vector POSITION=<-1.15, 0, 0.1>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 1) { vector POSITION=<-1.15, 0, -0.6>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 2) { vector POSITION=<-0.95, 0, -0.28>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 3) { vector POSITION=<-1.07, 0, -0.4>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 4) { vector POSITION=<-1.45, 0, -0.4>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else { vector POSITION=<-1.07, 0.70, -0.4>; vector Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } SitAnim=llGetInventoryName(INVENTORY_ANIMATION,randomSit); } else { integer perm=llGetPermissions(); if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(SitAnim)>0) llStopAnimation("sit"); llStopAnimation(SitAnim); SitAnim=""; } } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("sit"); llStopAnimation(SitAnim); llStartAnimation(SitAnim); llSay(0, (string)randomSit + ":" + SitAnim);
} } }
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
03-11-2007 12:59
I think the problem is that the Sit Target is being acquired as soon as the agent sits (just before the change event is triggered)... you then attempt to change it, but by then it's too late.
So Saddeus is suggesting that you you roll your llFrand, and set the Sit Target, as the agent is being unseated... ready for the next sitter.
|
|
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
|
03-11-2007 13:24
i understand what you mean but my knowledge of scripting is not good enough (yet) to make that.
i don't understand good enough how the different states work.
|
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
03-12-2007 00:22
Positon and rotation should be decided after the player stands up. And don't declear them more than once. Just edited your script, no test. vector POSITION =<-1.15, 0.0, 0.1>; vector Rotdeg = <0,270,0>;
string SitAnim; integer randomSit;
default { state_entry() { llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } on_rez(integer r) { llResetScript(); } changed(integer change) { if (change & CHANGED_LINK && llAvatarOnSitTarget()==NULL_KEY) { llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); } else { integer perm=llGetPermissions(); if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(SitAnim)>0) { llStopAnimation("sit"); llStopAnimation(SitAnim); SitAnim=""; randomSit = (integer)llRound(llFrand (5)); if(randomSit == 0) { POSITION=<-1.15, 0, 0.1>; Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 1) { POSITION=<-1.15, 0, -0.6>; Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 2) { POSITION=<-0.95, 0, -0.28>; Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 3) { POSITION=<-1.07, 0, -0.4>; Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else if(randomSit == 4) { POSITION=<-1.45, 0, -0.4>; Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } else { POSITION=<-1.07, 0.70, -0.4>; Rotdeg = <0,270,0>; llSitTarget(POSITION, llEuler2Rot(Rotdeg*= DEG_TO_RAD)); } SitAnim=llGetInventoryName(INVENTORY_ANIMATION,randomSit); } } } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("sit"); llStopAnimation(SitAnim); llStartAnimation(SitAnim); llSay(0, (string)randomSit + ":" + SitAnim);
} } }
_____________________
 Seagel Neville 
|
|
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
|
03-12-2007 12:14
Thanks Guys.
The script doen't work (Unable to find specified agent to request permissions) but i have some ideas the solve it. Have to learn more about states and events and the timing of them.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
03-12-2007 12:59
Somewhere in the middle of the many iterations of the code in this thread: if (change & CHANGED_LINK && llAvatarOnSitTarget()!=NULL_KEY)...has been changed to: if (change & CHANGED_LINK && llAvatarOnSitTarget()==NULL_KEY)Requesting permissions of a NULL_KEY will produce the error about being unable to find the specified agent... ie. Agent NULL_KEY.  I suspect Seagal may have missed this... I know I did.  Your code in message #4 was surely generating the exact same error? I think Seagal's mod is correct... you just need to put the != back in, but - and herein lies a word of caution - don't suppose that people helping you on this forum always spend the time to debug and test your code in-world. People are generally here to offer help, not fully unit-tested code samples. Although, sometimes you can get lucky.  Hehe... and just a couple more things. Your script currently only has one State (default). It has several Event Handlers (state_entry, on_rez, changed, and run_time_permissions). It has no Timer, and no User Defined Functions. Events arise as they occur (touch, rez, change link) and get queued to be presented to the script. A second event in the queue will not be handled by the script until the current Event Handler has finished executing. Execution of an Event Handler may itself give rise to new events (a permissions request) but these events will be placed on the queue behind any events already waiting. Events being generated within Event Handlers can be the most confusing. For example: llRequestPermissions, does not immediately cause the run_time_permissions Event Handler to execute. It will only execute once the current event, and all pending events, have been completed. This is described as Event Driven programming. HTH! 
|
|
Kaylan Draken
Registered User
Join date: 2 Dec 2006
Posts: 127
|
03-12-2007 13:36
Thanks for your explansion but i have solved it on another way.
i don't expect that people give me running and well tested code, i appreciate every sugestion i get to solve a problem.
i have solved it this way: 1: i put the llSitTarget and load animation code in the state_entry. 2: when the avi stand up call another state (state Reset) 3: in this state i call state default again, this forces to run the state_entry of state default again.
Thanks Pale, Seagel and Saddeus for the help i appreciate it.
|
|
Saddeus Toll
Registered User
Join date: 16 Jan 2007
Posts: 12
|
03-12-2007 16:55
From: Kaylan Draken Thanks Pale, Seagel and Saddeus for the help i appreciate it. You're welcome. Just don't forget to donate several L$ for a money tree for newbies :]
|