Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help With Wear Object > Click > Animate AV Script

Infrared Wind
Gridologist
Join date: 7 Jan 2007
Posts: 662
09-21-2008 22:12
Hi --

This little script, works almost perfect.

Wear the object that has this script, then click on the object and the animation starts.

But it "usually" (I think always) it requires two clicks on the object to get the animation started.

Can anyone tell me if there's a way to change this script so that it only takes one click to start the animation? Or if there's something wrong here.


CODE


integer ani;

string gAnimName = "animation_name";

default{
touch_start(integer num_touch)
{
ani=!ani;
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perm)
{

if (perm & PERMISSION_TRIGGER_ANIMATION)
{
if(ani){
llStartAnimation(gAnimName);
}
else
{
llStopAnimation(gAnimName);
}
}
}
}



thanks...
_____________________
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-21-2008 22:30
move ani=!ani; to the end of the touch event so it is called after the if functions
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-21-2008 22:32
this should work
From: someone

integer ani;

string gAnimName = "animation_name";

default{
touch_start(integer num_touch)
{

llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perm)
{

if (perm & PERMISSION_TRIGGER_ANIMATION)
{
if(ani){
llStartAnimation(gAnimName);
}
else
{
llStopAnimation(gAnimName);
}
ani=!ani;
}
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Infrared Wind
Gridologist
Join date: 7 Jan 2007
Posts: 662
09-21-2008 23:01
Ah...thank you, Ruthven! That's of course it.

- Infrared
_____________________
Infrared Wind
Gridologist
Join date: 7 Jan 2007
Posts: 662
09-22-2008 06:03
Actually I spoke too soon. I assumed the suggestion would work, but
didn't try it until now. And it didn't work.

But this does!

CODE


integer ani = 1;
string gAnimName = "animation_name";

default{
touch_start(integer num_touch)
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

on_rez(integer param)
{
llResetScript();
}

run_time_permissions(integer perm)
{

if (perm & PERMISSION_TRIGGER_ANIMATION)
{
if(ani){
llStartAnimation(gAnimName);
}
else
{
llStopAnimation(gAnimName);
}
}
ani=!ani;
}
}



The only difference is giving a value of 1 for the integer "ani", and placing
the "ani=!ani" one bracket down.

[Added:] the on_rez bit.

Thanks again Ruthven, for answering and setting me on the right path.

- Infrared
_____________________