Jump to content

Simple countdown timer


SeeAirAhh Josephina
 Share

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

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

Recommended Posts

I bet this is going to be something simple but I can't figure out what I'm doing wrong, thanks in advance for any help.

default
{
    state_entry()
    {
        count=0;
        llSetTimerEvent(1.0);
    }

    on_rez(integer num)
    {
        llResetScript();
    }
    
    timer()
    {
        llSetText("Countdown in: "+(string)(120-count)+"s\n \n \n ",<1,1,1>,1.0);
        count++;
        if (count>120)
//do something
}
}

 

Link to comment
Share on other sites

That's the idea.  You haven't included code to fill in what happens when you 

//do something

so that's probably why you're getting an error after the if statement.  Aside from that, you need to provide code to stop thee time when it reaches 120 seconds and the let you restart the timer (preferably without needing the reset the entire script).

Link to comment
Share on other sites

I think@Rolig Loon is correct and the lack of actual action is the issue.

Perhaps something like this?

integer giCount;
integer giStartCount = 120;

ResetTimer()
{
    giCount = giStartCount;
    llSetTimerEvent(1.0);
}

default
{
    state_entry()
    {
        ResetTimer();
    }

    touch_start(integer piNum)
    {
        ResetTimer();
    }

    on_rez(integer num)
    {
        llResetScript();
    }
    
    timer()
    {
        llSetText("Countdown in: "+ (string)giCount + "s\n \n \n ", <1.0, 1.0, 1.0>, 1.0);
        --giCount;
        if (giCount == 0)
        {
            //Do something
            llSetTimerEvent(0.0);
        }        
    }
}

 

  • Like 1
Link to comment
Share on other sites

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