Timer

Creating scripts
Post Reply
User avatar
Sarge Misfit
Posts: 254
Joined: Thu Mar 14, 2013 4:10 pm
Has thanked: 5 times
Been thanked: 223 times

Timer

Post by Sarge Misfit »

What is the smallest increment I can set for llSetTimerEvent(<time increment>)? As near as I can tell, its .1 seconds. Is that the case?
Living life on the wrong side of a one-track mind.

National Security Threat Level: Gnat

My site: Excelsior Station
My Kitely World: Misfit's Folly
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Timer

Post by Dundridge Dreadlow »

SL - 45 fps.
Kitely - About 55 fps

Do the maths :)

(There might be another imposed limit in the code somewhere)
...though I'm not sure why you'd need to check something that often..
ImageImageImageImageImageImage
PS. Kitely is awesome.
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Timer

Post by Dundridge Dreadlow »

it should drop events that it doesn't have time to execute though :D
ImageImageImageImageImageImage
PS. Kitely is awesome.
User avatar
Sarge Misfit
Posts: 254
Joined: Thu Mar 14, 2013 4:10 pm
Has thanked: 5 times
Been thanked: 223 times

Re: Timer

Post by Sarge Misfit »

Dundridge Dreadlow wrote:SL - 45 fps.
Kitely - About 55 fps

Do the maths :)

(There might be another imposed limit in the code somewhere)
...though I'm not sure why you'd need to check something that often..
??
I'm just wondering. I'm using a script that modifies a prim a specific way (profile cut) in 10 steps and uses the timer to time when to make each step. I'd like to keep the number of steps, but want to speed up the process. At this point, its set to .1 seconds, so it takes a full second to make the full profile cut. (its those doors you say at Regio Excelsior).

Code: Select all


integer Steps = 10;

float OpenState = 0.7;
float ClosedState = 0.25;

float hollow = 99.0;                    // 0.0 to 0.95
vector cut = <0.0, 1.0, 0.0>;
vector twist = <0, 0.0, 0.0>;          // -1.0 to 1.0
vector holesize = <0.01, 0.50, 0.0>;    // max X:1.0 Y:0.5
vector topshear = <0.0, 0.0, 0.0>;     // -0.5 to 0.5
vector profilecut = <0.0, 0.8, 0.0>;   // 0.0 to 1.0
vector taper_a = <0.0, 0.0, 0.0>;      // 0.0 to 1.0
float revolutions = 1.0;               // 1.0 to 4.0
float radiusoffset = 0.0;              // -1.0 to 1.0
float skew = 0.0;

string DoorOpening = "Door1";
string DoorCloseing = "Door1";
string DoorOpened = "Door1";
string DoorClosed = "Door1";

default
{
    state_entry()
    {
        profilecut.x = ClosedState;
        
        llSetPrimitiveParams([  PRIM_TYPE,
                                PRIM_TYPE_TORUS,
                                PRIM_HOLE_DEFAULT,
                                cut,
                                hollow,
                                twist,
                                holesize,
                                topshear,
                                profilecut,
                                taper_a,
                                revolutions, 
                                radiusoffset,
                                skew
                            ]);    
        state Closed;
    }
}

state Closed
{
    state_entry()
    {
        llSetTimerEvent(0.0);
        llMessageLinked(LINK_ALL_OTHERS, 0, "Closed", "");
        llPlaySound(DoorClosed,1.0);
    }

    link_message(integer Sender, integer Num, string Message, key SenderID)
    {
        if (Message =="Confirmed")
        {
            //go to door opening
            state Opening;
        }
    }
    
    touch_end(integer User)
    {
        llMessageLinked(LINK_ALL_OTHERS, 0, "OpenRequest", "");
    }
}

state Opening
{
    state_entry()
    {
        llSetTimerEvent(0.1); // can this be shortened?
        llMessageLinked(LINK_ALL_OTHERS, 0, "Opening", "");
        llPlaySound(DoorOpening,1.0);
    }
    
    timer()
    {
        profilecut.x = profilecut.x + ((OpenState - ClosedState) / Steps);
        
        if (profilecut.x >= OpenState)
        {
            profilecut.x = OpenState;
        }
        
        llSetPrimitiveParams([  PRIM_TYPE,
                                PRIM_TYPE_TORUS,
                                PRIM_HOLE_DEFAULT,
                                cut,
                                hollow,
                                twist,
                                holesize,
                                topshear,
                                profilecut,
                                taper_a,
                                revolutions, 
                                radiusoffset,
                                skew
                            ]);
        if (profilecut.x >= OpenState)
        {
            state Open;
        }
    }
    
    link_message(integer Sender, integer Num, string Message, key ID)
    {
        if (Message == "ForceClose");
        {
            state Closing;
        }
    }
}

state Open
{
    state_entry()
    {
        llSetTimerEvent(5.0);
        llMessageLinked(LINK_ALL_OTHERS, 0, "Open", "");
        llPlaySound(DoorOpened,1.0);
    }
    
    touch_end(integer IUser)
    {
        state Closing;
    }
    
    timer()
    {
        state Closing;
    }
    
    link_message(integer Sender, integer Num, string Message, key ID)
    {
        if (Message == "ForceClose");
        {
            state Closing;
        }
    }
}

state Closing
{
    state_entry()
    {
        llSetTimerEvent(.1); // can this bee shortened?
        llMessageLinked(LINK_ALL_OTHERS, 0, "Closing", "");
        llPlaySound(DoorCloseing,1.0);
    }
    
    timer()
    {
        profilecut.x = profilecut.x - ((OpenState- ClosedState) / Steps);
        
        if (profilecut.x <= ClosedState)
        {
            profilecut.x = ClosedState;
        }
        
        llSetPrimitiveParams([  PRIM_TYPE,
                                PRIM_TYPE_TORUS,
                                PRIM_HOLE_DEFAULT,
                                cut,
                                hollow,
                                twist,
                                holesize,
                                topshear,
                                profilecut,
                                taper_a,
                                revolutions, 
                                radiusoffset,
                                skew
                            ]);
                            
        if (profilecut.x <= ClosedState)
        {
            state Closed;
        }
    }
}
Living life on the wrong side of a one-track mind.

National Security Threat Level: Gnat

My site: Excelsior Station
My Kitely World: Misfit's Folly
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Timer

Post by Dundridge Dreadlow »

At 50fps, 1/50=0.02 seconds as a very very very quick timer... Highly not recommended. The system CAN handle it..

llSetPrimitiveParams takes 0.2 seconds :)

If you really want it to work this way, try llSetLinkPrimitiveParamsFast - it's almost the same, just modify slightly...

Code: Select all

 llSetLinkPrimitiveParamsFast(LINK_THIS,  [  PRIM_TYPE,
                                PRIM_TYPE_TORUS,
                                PRIM_HOLE_DEFAULT,
                                cut,
I'd really not recommend trying to alter an object with a timer more than 10fps (preferably less). Any lag of any kind will mess up the visual effect.
ImageImageImageImageImageImage
PS. Kitely is awesome.
User avatar
Sarge Misfit
Posts: 254
Joined: Thu Mar 14, 2013 4:10 pm
Has thanked: 5 times
Been thanked: 223 times

Re: Timer

Post by Sarge Misfit »

Thanks, Dundridge. I'll mess with ti as I get time :-)
Living life on the wrong side of a one-track mind.

National Security Threat Level: Gnat

My site: Excelsior Station
My Kitely World: Misfit's Folly
Post Reply