Jump to content

Press Button efect


Lolita Erin
 Share

Recommended Posts

Hello i am trying to make a panel control with couple buttons this is a Main Prim and 4 Linked prims (the buttons) i was wondering how can i acomplish and Effect to press the button (and keep it press until press again), i belive i have to move the linked prim and when press again move it to original position, is there any simple script to do this? thank for any help

Link to comment
Share on other sites

you need to get each link's local position, then set it and toggle the change...

 something like this.....? ( this assumes one button ... an ON button)

integer  linkNum;
vector currButton;

list paramsONbutton;
vector onButtonPos;
float ONzee = 0.05;

//add more button definitions here

default
{
    state_entry()
    {  paramsONbutton = llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL]);
       onButtonPos = llList2Vector(paramsONbutton,0);

       // add more buttons here
    }

    touch_start(integer total_number)
    {    linkNum = llDetectedLinkNumber(0);  
         if( linkNum == 2)
          { currButton = onButtonPos;
            llSetLinkPrimitiveParamsFast(linkNum,
            [ PRIM_POS_LOCAL, currButton - <0.0, 0.0, ONzee> ] );
            ONzee = -ONzee;
          }
      
        // add more link checks here
    }
}

  you will need a list , float and vector variable for each button prim,

 and IF statements for each button link number?

Link to comment
Share on other sites

You could do as Xijia suggests and use prim buttons that move up and down or you could take a very different route and swap textures on your button panel.  Make a texture that has all of your buttons on it and then make several variations that show different buttons in the Down (Pressed) position. If you have four panel buttons, for example, that means making five versions of the panel texture.  Then use llDetectedTouchST to detect which part of the textured penl a user has touched. Use llSetTexture or its llSetLinkPrimitiveParams equivalent to display the appropriate "Down button" image.  After a pause, switch back to the "Up" button image.

I have used that method very successfully on several projects.  It's fairly easy to script and it saves on prims (L.I.) in your project too.

Link to comment
Share on other sites

That all depends on how you wrote your script. When you take a scripted object to inventory, its script stops. It starts again when you rez the object from inventory, with all values exactly where you left them. If you want the script to do something different when you re-rez the object, you need to tell it that in an on_rez event. So ...

on_rez(integer startup) {     llResetScript(); /// Wipe all values and start over again}

 or

on_rez (integer startup) {     giNewTest = 0;    glResults = [];}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...