|
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.
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
|
|
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; } } }
|
|
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!
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
|