Jump to content

Script for selecting Script


pizbyskywere
 Share

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

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

Recommended Posts

I have two scripts, one for resizing and one to change textures on my hat
They're both TOUCH_START scripts and both of them open a Dialogue box with their options, if I click my hat, they open at the same time and conflict.

I want to make a script that relays on TOUCH_START to open a menu box so I can select one of those two scripts

how would I go about that?

thanks in advance!

Edited by pizbyskywere
Link to comment
Share on other sites

Change the touch_start event in each to a link_message event, and then write a simple menu script that sends a llMessageLinked poke to the appropriate script when you chose one of them.  With any luck, and if you had written those two scripts yourself or had mod perms, you could combine everything into a single script and save overhead.

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

Change the touch_start event in each to a link_message event, and then write a simple menu script that sends a llMessageLinked poke to the appropriate script when you chose one of them.  With any luck, and if you had written those two scripts yourself or had mod perms, you could combine everything into a single script and save overhead.

H47kEdS.png

Like this? what should I do next?

Link to comment
Share on other sites

That's the general idea, yes.  I assume that you are passing the integer "1" in the llMessageLinked statement in the script selection dialog as an indicator that the message is intended for the texture changer script.   In that case, you'll want to be sure that the link_message event in the texture changing script only accepts the message if (num == 1).  Then you do the same trick, using the integer "2" as your indicator for the resizing script.  

Now, I'm a little confused about why you have a llMessageLinked statement in the state_entry event of the texture changing script.  Unless there's something else going on here that you haven't mentioned, the texture changing script doesn't need to send link messages to anything.  It simply needs to receive the messages from the dialog selection script.  That's what its link_message event does.  You can't use llDetectedKey(0) there, though.  It's not detecting anything.  It's getting the toucher's UUID in the event's id variable. So, your test (if you need it at all) is if (id == llGetOwner() ).  Then user = id;

That should do it, although I'm sure you will have some tweaking to do around the edges.

Link to comment
Share on other sites

What I do in some cases is taking clicktime. (touch_start takes time and touch_end evaluates)

A normal click will run option1 and a long click (hold button maybe 2 seconds) will run option 2

No need for an extra menu and since resize will be used rarely that works for option2.

 

  • Like 1
Link to comment
Share on other sites

My take on using click length, like Nova suggests, to initiate two different actions uses a timer:

integer long_click;

default
{
    touch_start (integer count)
    {
        long_click = FALSE;
        llSetTimerEvent (0.35);
    }

    touch_end (integer count)
    {
        if (!long_click)
        {
            llSetTimerEvent (0.0);
            llOwnerSay ("Short click"); // do your short click stuff here
        }
    }

    timer ()
    {
        llSetTimerEvent (0.0);
        long_click = TRUE;
        llOwnerSay ("Long click"); // do your long click stuff here
    }
}

I find having the long click action initiate automatically after the button has been held down for long enough is more comfortable than having to hold down the mouse button and hoping you've held it down for long enough.

0.35 seconds seems about right for me. Anything less than 0.25 seems too susceptible to lag and clumsy clicking, while longer than 0.5 seems to take forever.

 

  • Like 1
Link to comment
Share on other sites

If you want to go down that road a different way, you could use a single click to trigger one action and a double click to trigger the other too....

float gHoldTime;
 
default
{
    touch_start(integer total_number)
    {
        float now = llGetTime();
        if (now - gHoldTime < 0.3)
        {
            llSay(PUBLIC_CHANNEL,"Double clicked");
            // Trigger one sequence of actions
        }
        else
        {
            llSetTimerEvent(0.32);
        }
        gHoldTime = now;
    }
 
    timer()
    {
        llSetTimerEvent(0.0);
        if (llGetTime()-gHoldTime > 0.3)
        {
            llSay(PUBLIC_CHANNEL,"Single clicked.");
            // Trigger a different sequence of actions
        }
    }
}

 

  • Like 2
Link to comment
Share on other sites

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