Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

touch_start animation while wearing it

Shjak Monde
Registered User
Join date: 10 Feb 2004
Posts: 111
07-29-2006 08:08
I am not much of a scripter so I need a little help.
I want to start an animation from an object I am wearing by clicking on it..
the script I have been trying to use looks like this.



CODE

default
{
touch_start(integer total_number)
{
if(llGetOwner() == llDetectedKey(0))
{
llStartAnimation("animnamehere");
}
}
}


is this broken? it sure is not working.
And yes I changed "animationhere" with the name of the animation thats located in that object.
LaZy Hulka
Registered User
Join date: 11 Apr 2006
Posts: 32
07-29-2006 13:20
This is a edit from old one I know this one should work.


CODE

integer lid;
integer listener; key owner;
default
{

touch_start(integer total_number)
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
owner = llGetOwner(); llListenRemove(listener); listener = llListen(0,"",owner,"");
llStartAnimation("animnamehere");

}
}
Ginge Reymont
Registered User
Join date: 10 Oct 2005
Posts: 190
07-29-2006 14:45
CODE

default
{
touch_start(integer total_number)
{
if(llGetOwner() == llDetectedKey(0))
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGG ER_ANIMATION);
owner = llGetOwner(); llListenRemove(listener); listener = llListen(0,"",owner,"");

}
}
run_time_permissions(integer perm)
{
if (perm == PERMISSION_TRIGGER_ANIMATION)
{
llStartAnimation("animnamehere");
}
}

}

Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
07-29-2006 18:56
CODE

default
{
touch_start(integer total_number)
{
if (llGetAttached ())
{
if(llGetOwner() == llDetectedKey(0))
{
llRequestPermissions (llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
}
}
run_time_permissions(integer perm)
{
if (PERMISSION_TRIGGER_ANIMATION & perm)
{
llStartAnimation("animnamehere");
}
}
}

If your animation doesn't stop by itself, you'll need to stop it when the object is detached.
Shjak Monde
Registered User
Join date: 10 Feb 2004
Posts: 111
07-30-2006 02:10
Thank you all for your attention on this problem.

The animation I have made stops itself for I have not set it to loop. So it should only play through once per click of the button.

The animation and the script is to go into an object that is attached to me "HUD"
Which have several buttons on it.. each button doing a diffent thing.
the desired action is that when I click the button the animation script runs an animation that is located in the same button the script resides in.

Angela..
your script worked great except I do have a problem with the permission menu droping requireing a "yes" button pushed before starting the animation.
Is there a way around this problem?
I think its the....
llRequestPermissions (llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
that causes the blue requirement permission window to drop...
Is it required to get permission from myself?
Being I am wearing the animation?

Ginge...
I could not get yours to work.. however after playing with it a bit.. I placed

integer lid;
integer listener; key owner;

on the first and second line, just before the line with the "Default" and then it worked.
However it also is requireing the permission window to be answered before starting the animation.

All your help is apreaceated thank you
Shjak Monde
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-30-2006 04:57
The only way around it is to wear the scripted item as an attachment AND make sure it's the root prim of the attachment.

Hmm, if it's in a pose ball you might be OK too actually, same was as furniture doesn't ask permissions normally.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Shjak Monde
Registered User
Join date: 10 Feb 2004
Posts: 111
07-30-2006 06:03
I have seen HUDs that have your AV perform animations and yet do not ask permission.
Some how they have gotten around this problem.
So would that mean there must be a call script and a listen script to call the root prim link?
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-30-2006 10:40
HUDs are an attachment, just like any other (except where they're shown/stored and a couple of odd quirks).

So if the HUD has the script in it's root prim it never pops up the blue box WHILST you're wearing it. Try rezzing an "on" AO on the ground - a lot of them will then pop up the blue box that they don't whilst you're wearing them.

Strictly speaking the script still asks permission, but because you're wearing it is automatically granted, so you don't see the blue box.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
07-30-2006 11:37
What you'll want to do instead then is have a single script handling the animation in the root of your object. Then in each button have a script that when touched uses llMessageLinked(LINK_ROOT, TRUE, NULL_KEY, "animationname";);

The root script then has a corresponding link_message() event to deal with the animation request, and code to ensure that permission is granted.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
07-30-2006 12:29
You really ought not to depend on run_time_permissions ONLY being called when you call llRequestPermissions(). Permissions can be taken away (for example, when you stand up from a sit), and there's been content broken in the past from depending on this.

I suggest something like this:

CODE

string requested_animation = "";

default()
{
touch_start(integer n)
{
if(llGetOwner() == llDetectedKey(0))
{
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
llStartAnimation("whatever");
else
{
requested_animation = "whatever";
llRequestPermissions(
llGetOwner(),
llGetPermissions() | PERMISSION_TRIGGER_ANIMATION
);
}
}
}

run_time_permissions(integer p)
{
if(requested_animation != "" && (p & PERMISSION_TRIGGER_ANIMATION))
{
llStartAnimation(requested_animation);
requested_animation = "";
}
}
}
Shjak Monde
Registered User
Join date: 10 Feb 2004
Posts: 111
07-30-2006 13:53
Thank you very Much Argent, that script saves me from the snowball effect he he.
weeeeeee
Shjak Monde