Script to play animation when object is worn
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
12-29-2007 14:51
I have previously used this script (PLAY ANIMATION WHEN WORN) succesfully to play an animation when an object is worn. I am trying to adapt it to play one of the "SL built in animations", which does briefly. I want it to persist as long as the object is worn. The other script below (START STOP ANIMATION WHEN TOUCHED) makes the same "SL built in animation" play repeatedly, it appears to do so by using a timer to make it repeat. I have tried adding a similar timer to the first script but it is not working. I bracketed the code I added to it with annotations "//added---------------------". I'm would appreciate any help in understanding how to do this correctly. Thanks PLAY ANIMATION WHEN WORN From: someone // Basic Animation / Attachment 1.0 // Catherine Omega Heavy Industries
string gAnimName = "express_open_mouth"; // what animation to play?
default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // ask the owner for permission to trigger animations llStartAnimation(gAnimName);
}
on_rez(integer param) { llResetScript(); // reset the script as soon as it starts. }
attach(key id) { integer perm = llGetPermissions();
if (id != NULL_KEY) // make sure we're actually attached. { if (! (perm & PERMISSION_TRIGGER_ANIMATION)) // remember to use bitwise operators! //added--------------------- llSetTimerEvent(0.5); //added--------------------- { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner. } } else { if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation(gAnimName); //added--------------------- llSetTimerEvent(0); //added--------------------- } } }
//added--------------------- timer() { llStopAnimation(gAnimName); llStartAnimation(gAnimName); } //added--------------------- }
START STOP ANIMATION WHEN TOUCHED From: someone //touching worn object will open close mouth
string ANIMATION = "express_open_mouth"; integer TouchSW;
default { state_entry() { llSay(0, "Open Mouth Animation"); if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } } changed(integer change) { if(change & 128) // You'd better put the this changed() event when you use llGetOwner { // by way of precaution. llResetScript(); } }
touch_start(integer total_number) { if(TouchSW == FALSE) { //llOwnerSay("Tongue Out"); llSetTimerEvent(0.5); } else { //llOwnerSay("Tongue In");
llSetTimerEvent(0); } TouchSW = !TouchSW; } timer() { llStopAnimation(ANIMATION); llStartAnimation(ANIMATION); } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
12-29-2007 18:50
Looks to me like you just need to move the added lines:
//added--------------------- llSetTimerEvent(0.5); //added---------------------
down below the permissions request lines:
{ llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner. }
so it reads like this:
if (! (perm & PERMISSION_TRIGGER_ANIMATION)) // remember to use bitwise operators! { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner. } //added--------------------- llSetTimerEvent(0.5); //added---------------------
You added those lines after the IF statement, so they do not set the timer if the permissions are already granted on the object. (the second time it is worn)
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
12-30-2007 09:40
Boss, thank you for the suggestion. Unfortunatly that didn't work, but I figure the script problem is something like that, I either have the "llSetTimerEvent(0.5);" in the wrong location or the "timer()".
I am a novice, mostly do cut and paste from other examples, I suspect I'm missing some basic understanding of how to properly structure scripts. I keep reading the wiki tutorials over and over, understanding a little more each time. I will keep working on it, thanks again for trying to help.
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
01-02-2008 09:48
This script works, the animation runs and repeats when the object is worn. EDIT: I got it working with the full original script plus the timer I added to it to play the SL Default animation. // Basic Animation / Attachment 1.0 // Catherine Omega Heavy Industries // Heavily modified by ArchTx Edo who is fully responsible for any stupid mistakes.
string gAnimName = "express_open_mouth"; // what animation to play?
default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // ask the owner for permission to trigger animations llSetTimerEvent(0.5);//I added this line. //llStartAnimation(gAnimName);
}
on_rez(integer param) { llResetScript(); // reset the script as soon as it starts. }
attach(key id) { integer perm = llGetPermissions();
if (id != NULL_KEY) // make sure we're actually attached. { if (! (perm & PERMISSION_TRIGGER_ANIMATION)) // remember to use bitwise operators! { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner. } } else { if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation(gAnimName); // stop the animation
} } } timer() { llStopAnimation(gAnimName); llStartAnimation(gAnimName); } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
MIT Bourne
Registered User
Join date: 12 Jan 2007
Posts: 20
|
own animation
01-16-2008 21:36
i tried it with my own animation ad it doesnt work, can i get some help on which part to edit to make it work with my own animation thanks in advance! =)
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
01-17-2008 03:07
From: MIT Bourne i tried it with my own animation ad it doesnt work, can i get some help on which part to edit to make it work with my own animation thanks in advance! =) string gAnimName = "express_open_mouth"; // what animation to play? exactly qoute the name of your animation where it says "express_open_mouth"
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
MIT Bourne
Registered User
Join date: 12 Jan 2007
Posts: 20
|
01-17-2008 19:04
From: Jesse Barnett string gAnimName = "express_open_mouth"; // what animation to play?
exactly qoute the name of your animation where it says "express_open_mouth" the name of my animation is "bend" and i tried editing into string gAnimName = "bend"; but it doesnt work, its an animation that i created using QAvimator and i named it "bend.bvh" and set it to priority 4.
|
Dogthinker Lemmon
Registered User
Join date: 26 Dec 2006
Posts: 5
|
01-17-2008 20:20
From: MIT Bourne the name of my animation is "bend" and i tried editing into string gAnimName = "bend"; but it doesnt work, its an animation that i created using QAvimator and i named it "bend.bvh" and set it to priority 4. Make sure the anim is inside the object with the script. If the anim is called bend.bvh inside SL, then you need gAnimName = "bend.bvh"; (Also... I expect you've already done this, but do make sure your anim works, by playing it straight out of your inventory, if you are new to uploading anims.  ) EDIT: also, you should only use the version of the original poster's script that uses the timer IF your anim does not play in a loop by itself (like the built in open mouth anim, which shuts the mouth again if you leave it playing.)
|
MIT Bourne
Registered User
Join date: 12 Jan 2007
Posts: 20
|
01-20-2008 19:02
thanks i got it! =)
|
MIT Bourne
Registered User
Join date: 12 Jan 2007
Posts: 20
|
01-22-2008 01:37
is there any way to stop the avatar from doing random animations like placing the arms on the hips?
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-22-2008 04:12
animations at priority3 and 4 should override the default stands (like hands on hips), the other optiion is an AO the kills the specific animations using llGetAnimationList and llStopAnimation looped through that list... alternately you could just repeatedly call stop animation on the specific one your want to stop
_____________________
| | . "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... | - 
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-22-2008 09:16
Remember though that a higher priority animation will only "overwrite", as it were, the movements of a lower priority animatinon on the bodyparts the higher priority animation actually animates (when you make the animation, it is a good idea to make at least two frames and never modify the very first; bodyparts whose position settings aren't changed at all throughout the animation will not be animated).
|
MIT Bourne
Registered User
Join date: 12 Jan 2007
Posts: 20
|
01-23-2008 23:05
From: Void Singer animations at priority3 and 4 should override the default stands (like hands on hips), the other optiion is an AO the kills the specific animations using llGetAnimationList and llStopAnimation looped through that list... alternately you could just repeatedly call stop animation on the specific one your want to stop thanks, may i know what is the hands on hip animation called?
|