Script syncstart

From The SchomEmunity Wiki
Jump to: navigation, search

This is a script which can be put in multiple objects to force scripts to start at an iteration of a time period, i.e. have many things start on the hour. --Olly 13:20, 16 May 2007 (BST)

//syncstart v1.0
//15/5/07
//Author: Olly Butters
//Part of the schome initiative. (www.schome.ac.uk)
//You may copy/edit this, but please credit us.
//Gets number of seconds since midnight and makes the timer event start at the next iteration of the period. Used to sync multiple things.
integer OllyTime;
integer period = 300;
default
{
    
    touch_start(integer total_number)
    {
        integer OllyTime=(integer)llGetGMTclock(); //seconds since midnight
        llSay(0,(string)OllyTime);
        
        while(OllyTime>period) //makes less than or equal to the period
        {
            OllyTime = OllyTime - period;
        }
        OllyTime = period - OllyTime; //seconds until next period iteration
        llSay(0,(string)OllyTime);
        llSleep((float)OllyTime); //wait
        llSetTimerEvent(period); //GO
        llSay(0,"done sleeping at");
        llSay(0,(string)llGetGMTclock());
    }
    
    timer()
    {
        llSay(0,(string)llGetGMTclock());
    }

}