Jump to content

Left click animation script help


Vollrath
 Share

You are about to reply to a thread that has been inactive for 4044 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Here it is;

 

default
{
attach(key id)
{
if(id){
llRequestPermissions(id, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
}
}

control(key id, integer held, integer press){
if(press){
if(held) llStartAnimation("INVENTORY_ANIMATION");
else llStopAnimation("INVENTORY_ANIMATION");
}
}
}

 

What I need help with is getting this to play multiple animations from the objects inventory. Not all at once, but one per left click of the mouse. Not left clicking on the object, like on the ground or in mouselook. I'm pretty sure there is a way to do this without listing each animation in the script.

Any advice?

Link to comment
Share on other sites

I would do something like this, I think:

 

integer counter;integer max;list animations;string previousAnim ="standing";string newAnim;default{	state_entry(){		max = llGetInventoryNumber(INVENTORY_ANIMATION);		counter =0;		do {			animations+=[llGetInventoryName(INVENTORY_ANIMATION,counter)];		}		while (++counter<max);		counter =0;		max = llGetListLength(animations);	}	attach(key attached)	{		//do stuff	}	run_time_permissions(integer permissions)	{		//do stuff	}	control(key id, integer held, integer change) {		integer pressed = held & change;		integer down = held & ~change;		integer released = ~held & change;		integer inactive = ~held & ~change;		if (pressed & CONTROL_LBUTTON){			newAnim = llList2String(animations,(counter%max));			if(llGetPermissions()&PERMISSION_TRIGGER_ANIMATION){				llStartAnimation(newAnim);				llStopAnimation(previousAnim);				previousAnim=newAnim;				++counter;			}		}	}}

 

Link to comment
Share on other sites

Ok, I started over with what Innula posted, and added what Qie said I needed. Still nothing happening on a left click.

Here is what it looks liek now:

integer counter;
integer max;

list animations;
string previousAnim ="standing";
string newAnim;
default
{
state_entry(){
max = llGetInventoryNumber(INVENTORY_ANIMATION);
counter =0;
do {
animations+=[llGetInventoryName(INVENTORY_ANIMATION,counter)];
}
while (++counter<max);
counter =0;
max = llGetListLength(animations);
}

attach(key attached)
{
llRequestPermissions(attached, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer permissions)
{
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
}

 

control(key id, integer held, integer change) {

integer pressed = held & change;
integer down = held & ~change;
integer released = ~held & change;
integer inactive = ~held & ~change;

if (pressed & CONTROL_LBUTTON){
newAnim = llList2String(animations,(counter%max));
if(llGetPermissions()&PERMISSION_TRIGGER_ANIMATION){
llStartAnimation(newAnim);
llStopAnimation(previousAnim);
previousAnim=newAnim;
++counter;
}
}
}
}

Link to comment
Share on other sites

This is what I ended up with -- setting the string previousAnim to "standing" (or "Standing") doesn't work, it turns out, so I had misunderstood how the recent AO script functions work.  Plus, of course, it wouldn't do much anyway if you're using a traditional AO.

integer counter;integer max;list animations;string previousAnim ="";string newAnim;stopAnims(key av){    list l = llGetAnimationList(av);    integer max = -llGetListLength(l);    do {        llStopAnimation(llList2Key(l,max));        llSleep(0.2);    }    while (++max);}init(){     max = llGetInventoryNumber(INVENTORY_ANIMATION);        counter =0;        do {            animations+=[llGetInventoryName(INVENTORY_ANIMATION,counter)];        }        while (++counter<max);        counter =0;        max = llGetListLength(animations);   }default{    state_entry(){      init();    }        changed(integer change){        if (change & CHANGED_INVENTORY){            init();        }    }        attach(key attached)    {        if (attached){        previousAnim="";        init();        llRequestPermissions(attached, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);        }    }    run_time_permissions(integer permissions)    {        llTakeControls(CONTROL_LBUTTON, TRUE, TRUE);    }    control(key id, integer held, integer change) {        integer pressed = held & change;        integer down = held & ~change;        integer released = ~held & change;        integer inactive = ~held & ~change;        if (pressed & CONTROL_LBUTTON){                        newAnim = llList2String(animations,(counter%max));            if(llGetPermissions()&PERMISSION_TRIGGER_ANIMATION){                if (previousAnim==""){                    stopAnims(id);                     llStartAnimation(newAnim);                }                else{                llStartAnimation(newAnim);                llStopAnimation(previousAnim);                }                previousAnim=newAnim;                ++counter;            }        }    }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4044 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...