Jump to content

One mouse click more than one control event?


Estelle Pienaar
 Share

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

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

Recommended Posts

I have a little script that should perform a function when the left mouse button is clicked. However, no matter how quickly I try to click the left mouse button, the control event is triggered at least 3  times per qulick. If I keep the left mouse button pressed down, I get an even greater amount of triggered events. How can I change my code, so that the control event will only be triggered once per mouse click?

 

key ownerK;

default
{
    state_entry()
    {

        ownerK = llGetOwner();
        
    }
  attach(key id)
    {
           if (id)     
        {
            if (id != ownerK)
            llResetScript(); 
        
            else
            llRequestPermissions(id, PERMISSION_TAKE_CONTROLS);
        }
        else
            llReleaseControls( );
         
    }

run_time_permissions(integer perm)
    {
        if(PERMISSION_TAKE_CONTROLS & perm)
        {
                llTakeControls(CONTROL_LBUTTON, TRUE, TRUE);                 
                
        }   

    }
    control (key id, integer level, integer edge)
    {
        Detected = [];
        llOwnerSay("Debugging: I have been clicked");
        
    }
}

 

Link to comment
Share on other sites

If you look at this page: http://wiki.secondlife.com/wiki/Control, then you see that there is a number describing LCONTROL: 0x10000000. It is an hexadecimal number which you can convert to decimal with Windows calculator in programmer mode. So it is 268435456 in decimal. When you click the mouse button you will get that number in level and edge, when you release the mouse button level will be 0. Note that this works only because you listen to only one button, if you were listening to more controls you would have to check the states with boolean operations as described on the wiki.


 

 

 

 

 

  • Like 1
Link to comment
Share on other sites

47 minutes ago, Mollymews said:

Estelle we can test for mouse_down, mouse_up and mouse_press

example to test for mouse_down

Look at the wiki example for the others

http://wiki.secondlife.com/wiki/LlTakeControls

Thank you very much, for making this evident. It is rather poorly explained in the wiki. There are these integers in the example script, but not at all explained in a clear way. However when you said it, I understood it in an instant.

Edited by Estelle Pienaar
  • Like 1
Link to comment
Share on other sites

yes it can be a bit unclear in the beginning

with the wiki code example the variables names are: start, end, held and untouched

which is clear as mud until we get better at reading mud 

when we think in terms of key_down, key_press and key_up, as in your case mouse_down, mouse_press and mouse_up then is lots more readable. Particularly if we have some previous experience in tools like Visual Basic, Delphi, C#, etc

  • Like 1
Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...