Jump to content
Sign in to follow this  
Honza Noyes

Obvious control(...) event behavior

Recommended Posts

Good day,
I was writing a script today, and I ran into a very obvious behavior, the following script looks like this:

float rof_time;
integer rof_count;

Fire()
{
    rof_count++;
    llSleep(0.1 * llGetRegionTimeDilation());
}

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
    }
    
    run_time_permissions(integer perm)
    {
        if(perm)
        {
            llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
        }
    }
    
    control(key id, integer level, integer edge)
    {
        if((level & edge) & CONTROL_ML_LBUTTON)
        {
            rof_time = llGetTime();
            rof_count = 0;
            Fire();
        }
        else if(level & CONTROL_ML_LBUTTON)
        {
            Fire();
        }
        else if((~level & CONTROL_ML_LBUTTON) && (edge & CONTROL_ML_LBUTTON))
        {
            llSay(0, "ROF:" + (string)(rof_count/(llGetTime() - rof_time)) + "BPS");
        }
    }
}

Now the following script after being dropped into an object and worn, holding CONTROL_ML_LBUTTON and than releasing it should say 'ROF:10BPS' which it does in a regular sim (homestead or full, doesn't matter at all), but in a little lag, it reuturns 'ROF:<10BPS'. Now here comes the thing, when you standing the returned ROF is lower than 10 in lag, but when you press CONTROL_FWD or any other button and start moving, than hold the CONTROL_ML_LBUTTON and than release it, the script returns 'ROF:10BPS' which is correct.

So here is the question, is this a bug or expected behavior since I am not taking control of CONTROL_FWD or other movement buttons, however they affect the script?

Share this post


Link to post
Share on other sites

I reproduce it when i comment the llsleep .

 

But i guess it s a normal comporment .

Indeed , when you move , you generate control events with you button mouse pressed and your keyboard pressed 

When you don t move you generate less control events  with only your button mouse pressed

When you rotate the camera with the mouse , you will have something  , for instance with 38 BPS . 

And if you rotate the camera as fast as you can , you will have something  as 44-45 BPS

Maybe the viewer receives more events from your OS ( windows/Linux , mac)  , because it receives the events  from the OS for the the button pressed and for the moves of your mouse . And , so it sends more events to the server . And so the server replies more control events to the script 

 

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

If accept is TRUE and pass_on is FALSE, then the specified controls are disabled (but generate control events), and all other controls behave normally.



Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...