Simple pose/animation script
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
02-06-2006 06:34
Can someone please post a simple pose/animation script to make a pose table? Clicking it to move to the next pose? I could have sworn I saw it here a couple of weeks ago but can't seem to find it. Thanks!
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
Found it!
02-06-2006 13:12
Ok, I found it. If I am not using it and touch it, I get this message in 2 little blue popup screens: Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set If I am not using it and touch it, it should whisper something like "Right click and Sit to Use Me" instead of getting this funky error message. Any ideas? Thx //Started as the free posing stand script, adapted to accommodate models with multiple poses by Varick Eisenberg. //Click cycle features and listen features added by Varick Eisenberg as well. //Note: this code was adapted from someone. // key mkLoungingAgentKey = NULL_KEY; key agent; integer miPermissionsAcquired = FALSE; string current; string current2; string command = "set"; string command2 = "stop"; string setanim; string stopanim; integer next = 0; integer limit; default { state_entry() { llListen(0, "", llGetOwner(), ""); //overriden sit target //lower them a bit vector vLoungeTarget = <0.00, 0.00, 1.35>; rotation rX; rotation rY; rotation rZ; rotation r; //build rotations //Note: this is broken out like this to simplify the // process of finding the correct sit angle. I // use the following form until I have the rotation // that I want perfect, and then I simply // hardcode the perfected quaterion and remove // this mess. // rX = llAxisAngle2Rot( <1,0,0>, 0 * DEG_TO_RAD); //cartwheel rY = llAxisAngle2Rot( <0,1,0>, 0 * DEG_TO_RAD); //sumersault rZ = llAxisAngle2Rot( <0,0,1>, 0 * DEG_TO_RAD); //turn in place //combine rotations r = rX * rY * rZ; //override 'sit' on pie menu llSetSitText( "Pose" ); //override default sit target and rotation on prim llSitTarget( vLoungeTarget, r ); //gets total number of animations in inventory to know how many to cycle through limit = llGetInventoryNumber(INVENTORY_ANIMATION); } changed(integer change) { //this checks to see if any new animations have been added, and if so, then changes the limit integer to match if (change & CHANGED_INVENTORY); { limit = llGetInventoryNumber(INVENTORY_ANIMATION); } //this checks to see if anyone has sat/gotten off the stand if (change & CHANGED_LINK) { agent = llAvatarOnSitTarget(); if ( mkLoungingAgentKey == NULL_KEY && agent != NULL_KEY ) { //changed user //cache new user key and request their permissions mkLoungingAgentKey = agent; llRequestPermissions(mkLoungingAgentKey,PERMISSION_TRIGGER_ANIMATION); } else if ( mkLoungingAgentKey != NULL_KEY && agent == NULL_KEY) { //user is getting up if ( miPermissionsAcquired ) { //restore anims llStopAnimation("stand"); } //reset the script to release permissions llResetScript(); } } } listen(integer channel, string name, key id, string message) { if (llSubStringIndex(message, command) == 0) { //parse out the name of the animation integer spaceIdx = llSubStringIndex(message, " "); setanim = llGetSubString(message, spaceIdx + 1, -1); llStopAnimation(current); llStartAnimation(setanim); current = llList2String(llGetAnimationList(agent), 0); llWhisper(0, "Starting: "+setanim); } if (llSubStringIndex(message, command2) == 0) { //parse out the name of the animation integer spaceIdx = llSubStringIndex(message, " "); stopanim = llGetSubString(message, spaceIdx + 1, -1); llStopAnimation(stopanim); llWhisper(0, "Stopping: "+stopanim); } //if the message in all lowercase equals hide stand then the stand will become invisible if (llToLower(message) == "hide table") { llSetAlpha(0, ALL_SIDES); } //same as above but makes the stand visible at the message show stand if (llToLower(message) == "show table") { llSetAlpha(1, ALL_SIDES); } } //the below happens when someone touches it touch_start(integer num) { //set permission flag miPermissionsAcquired = TRUE; //stops what's happening right now llStopAnimation(current); //starts the next animation in the inventory llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, next)); //sets the current animation to what was just changed to current = llGetInventoryName(INVENTORY_ANIMATION, next); llWhisper(0, current); //ups the next integer by 1 so that next time this is run the next animation in the list is used next++; //checks to see if the current animation has reached the end of the number of the anims if( next == limit) { //if so then it resets next to 0 next = 0; } } run_time_permissions(integer parm) { if(parm == PERMISSION_TRIGGER_ANIMATION) { //set permission flag miPermissionsAcquired = TRUE; //cancel the sit anim llStopAnimation("sit"); //starts the default anim for this stand llStartAnimation("stand"); //sets the current to the default anim current = "stand"; } } }
|
|
Upshaw Underhill
Techno-Hobbit
Join date: 13 Mar 2003
Posts: 293
|
02-06-2006 15:46
I'm at work so can't compile script so dont expect it to work without a little tweaking  , but the main thing you need is... //Started as the free posing stand script, adapted to accommodate models with multiple poses by Varick Eisenberg. //Click cycle features and listen features added by Varick Eisenberg as well. //Note: this code was adapted from someone. // key mkLoungingAgentKey = NULL_KEY; key agent; integer miPermissionsAcquired = FALSE; string current; string current2; string command = "set"; string command2 = "stop"; string setanim; string stopanim; integer next = 0; integer limit;
default { state_entry() {
llListen(0, "", llGetOwner(), "");
//overriden sit target //lower them a bit vector vLoungeTarget = <0.00, 0.00, 1.35>;
rotation rX; rotation rY; rotation rZ; rotation r;
//build rotations //Note: this is broken out like this to simplify the // process of finding the correct sit angle. I // use the following form until I have the rotation // that I want perfect, and then I simply // hardcode the perfected quaterion and remove // this mess. // rX = llAxisAngle2Rot( <1,0,0>, 0 * DEG_TO_RAD); //cartwheel rY = llAxisAngle2Rot( <0,1,0>, 0 * DEG_TO_RAD); //sumersault rZ = llAxisAngle2Rot( <0,0,1>, 0 * DEG_TO_RAD); //turn in place
//combine rotations r = rX * rY * rZ;
//override 'sit' on pie menu llSetSitText( "Pose" ); //override default sit target and rotation on prim llSitTarget( vLoungeTarget, r );
//gets total number of animations in inventory to know how many to cycle through limit = llGetInventoryNumber(INVENTORY_ANIMATION); }
changed(integer change) { //this checks to see if any new animations have been added, and if so, then changes the limit integer to match if (change & CHANGED_INVENTORY); {
limit = llGetInventoryNumber(INVENTORY_ANIMATION);
} //this checks to see if anyone has sat/gotten off the stand if (change & CHANGED_LINK) {
agent = llAvatarOnSitTarget();
if ( mkLoungingAgentKey == NULL_KEY && agent != NULL_KEY ) { //changed user //cache new user key and request their permissions mkLoungingAgentKey = agent;
llRequestPermissions(mkLoungingAgentKey,PERMISSION _TRIGGER_ANIMATION);
} else if ( mkLoungingAgentKey != NULL_KEY && agent == NULL_KEY) {
//user is getting up if ( miPermissionsAcquired ) {
//restore anims llStopAnimation("stand");
}
//reset the script to release permissions llResetScript(); } } }
listen(integer channel, string name, key id, string message) {
if (llSubStringIndex(message, command) == 0) {
//parse out the name of the animation integer spaceIdx = llSubStringIndex(message, " ");
setanim = llGetSubString(message, spaceIdx + 1, -1);
llStopAnimation(current);
llStartAnimation(setanim);
current = llList2String(llGetAnimationList(agent), 0);
llWhisper(0, "Starting: "+setanim);
}
if (llSubStringIndex(message, command2) == 0) {
//parse out the name of the animation integer spaceIdx = llSubStringIndex(message, " ");
stopanim = llGetSubString(message, spaceIdx + 1, -1);
llStopAnimation(stopanim);
llWhisper(0, "Stopping: "+stopanim);
}
//if the message in all lowercase equals hide stand then the stand will become invisible if (llToLower(message) == "hide table") {
llSetAlpha(0, ALL_SIDES);
}
//same as above but makes the stand visible at the message show stand if (llToLower(message) == "show table") {
llSetAlpha(1, ALL_SIDES);
} }
//the below happens when someone touches it touch_start(integer num) { agent = llAvatarOnSitTarget(); if (agent == NULL_KEY) {llWhisper(0,"Right-Click and choose Sit to start Posing.");} else if ( mkLoungingAgentKey == NULL_KEY && agent != NULL_KEY ) { //changed user //cache new user key and request their permissions mkLoungingAgentKey = agent;
llRequestPermissions(mkLoungingAgentKey,PERMISSION _TRIGGER_ANIMATION); } if (miPermissionsAcquired == TRUE) { //stops what's happening right now llStopAnimation(current);
//starts the next animation in the inventory llStartAnimation(llGetInventoryName(INVENTORY_ANIM ATION, next));
//sets the current animation to what was just changed to current = llGetInventoryName(INVENTORY_ANIMATION, next); llWhisper(0, current);
//ups the next integer by 1 so that next time this is run the next animation in the list is used next++;
//checks to see if the current animation has reached the end of the number of the anims if( next == limit) {
//if so then it resets next to 0 next = 0;
} } } run_time_permissions(integer parm) { if(parm == PERMISSION_TRIGGER_ANIMATION) {
//set permission flag miPermissionsAcquired = TRUE;
//cancel the sit anim llStopAnimation("sit");
//starts the default anim for this stand llStartAnimation("stand");
//sets the current to the default anim current = "stand"; } } }
you cant just set miPermissionsAcquired = TRUE; you have to let the permissions event do that and if it isn't set you have to just do the Whisper. L8r, UU P.S. if you cant get my hacked together code to compile I'll put together a finished one this evening... been meaning to add this to my own stand rather than just the voice commands anyway 
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
02-06-2006 15:54
Thanks UU, I'll give it a go after I get dinner cooked and then I'll post back. If you do get home and get a chance to get the finished code u before I do, I'd appreciate that too  Good evening! Mad
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
02-06-2006 16:36
Needed some } at the end, and it compiled, but that silly blue box still popped up.
|
|
Upshaw Underhill
Techno-Hobbit
Join date: 13 Mar 2003
Posts: 293
|
02-06-2006 17:52
ack, one silly = the line which reads if (miPermissionsAcquired = TRUE)
should read if (miPermissionsAcquired == TRUE)
and all will be well  L8r, UU
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
02-06-2006 20:09
You Rock!!! Hugz 
|
|
Lor Goodliffe
Registered User
Join date: 26 Dec 2005
Posts: 5
|
I am seeing one odd Problem
02-15-2006 23:30
When I uses this script in a prim that is not the root of a linked set, dismounts do not happen correctly. When I stand up, I am still in the sitting pose.
If the prim is the root of the linked set, or is a stand alone prim there are no problems.
What is causing this odd dismount behavior, and how do I fix it?
Thank you Lor Goodliffe
|