Jump to content

a little favor


eduardoalonzo
 Share

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

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

Recommended Posts

I bought this stand pose script and I would like it to disappear when I sit down and appear again when I get up, I know that for you geniuses and sages of SL it is easy, do me that favor- please rewrite it, and also cancel the text on the stand pose

 

integer itemType=INVENTORY_ANIMATION;
vector posePos=<0,0,1.3>;
integer itemCount;
integer counter=0;
string animation;
key sitavakey=NULL_KEY;

stopAnimation() {
       list anims = llGetAnimationList(llGetPermissionsKey());
       integer aminct = llGetListLength(anims);
       integer i;
       for (i = 0; i < aminct; i++){
               llStopAnimation(llList2Key(anims, i));
       }
}

startAnimation(integer num) {
    if (itemCount==0) return;
    stopAnimation();
    counter+=num;
    if (itemCount<=counter)
        counter=0;
    else if (counter==-1)
        counter=itemCount-1;
    
    animation=llGetInventoryName(itemType,counter);
    showText();
    llStartAnimation(animation);
}

showText() {
    itemCount = llGetInventoryNumber(itemType);
    string msg;
    if (sitavakey==NULL_KEY)
        msg="-- PoseStand --\n" + (string)itemCount + " animations";
    else
        msg="-- PoseStand --\n" + animation + "(" + (string)(counter+1) + "/" + (string)itemCount + ")";
        
    llSetText(msg,<1,1,1>, 1.0);
}

default {
    
    state_entry(){ 
        llSetSitText("Pose");
        llSitTarget(posePos,ZERO_ROTATION);
        showText();
    } 

    on_rez(integer int) {
        llResetScript(); 
    }
    
    changed(integer change) {
        if (change & CHANGED_LINK) {
            sitavakey = llAvatarOnSitTarget(); 
            if( sitavakey != NULL_KEY ) { 
                if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) 
                        && llGetPermissionsKey() == sitavakey) { 
                    startAnimation(0);
                } else { 
                    llRequestPermissions(sitavakey, PERMISSION_TRIGGER_ANIMATION); 
                } 
            } else {
                animation="";
                counter=0;
                showText();
            }
        } else if (change & CHANGED_INVENTORY) {
            showText();
        }
    } 

    run_time_permissions(integer perm){ 
        if(perm & PERMISSION_TRIGGER_ANIMATION){ 
            startAnimation(0);
        } 
    } 
    
    link_message(integer sender_num, integer num, string str, key id){
        if (llGetPermissionsKey() == sitavakey) {
            startAnimation(num);
        }
    }
    
}
 

Edited by eduardoalonzo
Link to comment
Share on other sites

The function you want is llSetAlpha, which you can look up in the LSL wiki here.  Your changed event has two branches.  One, following the line marked 

 if( sitavakey != NULL_KEY ){ 

tells the script what to do when you sit down.  The other, in the block

} else {
                animation="";
                counter=0;
                showText();
            }

tells the script what to do when you stand up. So, llSetAlpha(0.0); when you sit down and llSetAlpha(1.0); when you stand up.

Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

The function you want is llSetAlpha, which you can look up in the LSL wiki here.  Your changed event has two branches.  One, following the line marked 

 if( sitavakey != NULL_KEY ){ 

tells the script what to do when you sit down.  The other, in the block

} else {
                animation="";
                counter=0;
                showText();
            }

tells the script what to do when you stand up. So, llSetAlpha(0.0); when you sit down and llSetAlpha(1.0); when you stand up.

aya my head hurts 100 attempts and I only managed to make it disappear but it doesn't appear again   :c

Link to comment
Share on other sites

Great!  So you have accomplished two things.  You made the object disappear, so you know that you put that first llSetAlpha command in the right place, and you got a headache, which says that you are thinking hard.  So, look at that block of things that the script is supposed to do when you stand up:

} else {
                animation="";
                counter=0;
                showText();
            }

The script will set the name of the animation to "" (which means, essentially, that it forgets the name of the animation). Then it will set its own variable counter to zero. Finally, it will refresh the floating text over your object by calling its own showText function.  And you want it to do one more thing ... make the object visible again.  So that's where you put the second llSetAlpha command, as a new line among the other three things.  With any luck (no typos), that should do it.  Try sitting on it to see.

When you come to the Scripting forum, we assume that you are a scripter or at least are willing to learn.  We won't usually write your script for you because that's your job, but I hope this helps you see how to do one small thing.  Now you are a scripter.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1427 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...