2011-08-31

Knowing when your region has restarted

Often I'll be in-world when a rolling restart comes around. When this happens I'll generally TP away (usually to Z&A's "head office" -- a little 512 plot we have where we keep backup magic boxen and the like). Once there it's always been a case of either checking the map (not reliable at all), attempting to get landmark information (also not reliable) or attempting to TP home (fails: not back up, works: back up) so as to find out if the home sim is back.

None of them are the smartest solutions. So, a few months back, I realised that the simplest solution was to rez a prim (in this case in the Z&A workshop), throw it on the "gadget self" and have it detect when the sim is back and IM me. The code is simple enough:

//////////////////////////////////////////////////////////////////////
// Sim Restart Notifier -- By Antony Fairport
//
// IMs you when the sim it is located on restarts. Handy during
// rolling restarts when you've had to run away and want to be told
// as soon as it's back up.
//
// Revision history:
// ------------------------------------------------------------
//
// 2011-05-31
// First version.
string g_sLastRestart = "";
//////////////////////////////////////////////////////////////////////
// Format a llGetTimestamp()
string FormatTime( string sTime )
{
list l = llParseString2List( sTime, [ "T", "." ], [] );
return llList2String( l, 0 ) + " " + llList2String( l, 1 ) + " UTC";
}
//////////////////////////////////////////////////////////////////////
// Sim Restart Notifier -- Antony Fairport
default
{
//////////////////////////////////////////////////////////////////
// React to a touch.
touch_start( integer num_detected )
{
// If we don't have a last restart time...
if ( g_sLastRestart == "" )
{
// ...so say.
llWhisper( 0, "No restart has been recorded yet." );
}
else
{
// Otherwise say what the last recorded restart time is.
llWhisper( 0, "Last restart was " + g_sLastRestart );
}
}
//////////////////////////////////////////////////////////////////
// React to changes.
changed( integer change )
{
// If the region has started...
if ( change & CHANGED_REGION_START )
{
// ...IM me to let me know it's back.
llInstantMessage( llGetOwner(), llGetRegionName() + " has restarted." );
g_sLastRestart = FormatTime( llGetTimestamp() );
}
}
}
As you can see, I've also made it so that a touch tells the last restart detected.

The handy thing about this is that I have offline IMs going to email so if the sim gets a restart when I'm not in-world I'll also get to know about it.

No comments:

Post a Comment