Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Please glance at Online indicator script

Dr Drebin
Registered User
Join date: 19 Mar 2006
Posts: 66
06-24-2006 15:56
I pulled this out of the Library (Wiki) and it works... But it stores old data, and when I rez it I have to recompile/start running to get it to update correctly.

I would like to make it update automatically (10+ minutes?), or if that is too server intensive, at least when the object is touched.

I modified names and Agent keys to protect the guilty.

Thank you all.
(I can't make the "foo Name" lines ident properly on this board, but the alignment on everything else looks as written)

CODE
 
// Scan for online status on the main grid.
// Just drop this script into something
// by Keknehv Psaltery -- 03/08/06
list mentors = ["foo Name1" ,"f1xxxx9a-210b-4b00-96d7-ab16c962a40f",
"foo Name2" ,"4xxxx04e-bfcb-7bff-b34b-bf9b7ce7c91b",
"foo Name3" ,"33xxxx04-b6cd-72c9-ae01-fb2e617c79ff"];

key dataKey;
integer currentMentor;
integer numberMentors;
float startTime;
list onlineMentors;
float percentDone;
default
{
state_entry()
{
currentMentor = 0;
numberMentors = llGetListLength( mentors ) / 2;
startTime = llGetTime();
dataKey = llRequestAgentData( (key)llList2String(mentors,currentMentor*2+1),
DATA_ONLINE );
}
dataserver( key query, string data )
{
if ( query == dataKey )
{
if ( (integer)data ) //Are they online?
onlineMentors += [llList2String(mentors,currentMentor*2)];

++currentMentor;

percentDone = (float)currentMentor / numberMentors;

//This next line is ugly. Beware!
llSetText( "Scanning for online scripting mentors\n Currently " +
(string)currentMentor +"/"+ (string)numberMentors + " -- " +
llGetSubString((string)(percentDone*100),0,3) +
" percent complete\n" +
llGetSubString((string)((llGetTime()-startTime)/(percentDone)*(1-percentDone)),0,3) +
" seconds remaining\n Online:\n " + llDumpList2String( onlineMentors , "\n" )
, <1.01-percentDone,percentDone,0.0>, percentDone + .4);

if ( currentMentor < numberMentors )
dataKey = llRequestAgentData( (key)llList2String(mentors,currentMentor*2+1),
DATA_ONLINE );
else
{
llSetText( "Scan Time: " + llGetSubString((string)((llGetTime()-startTime)),0,3) +
" seconds\nScripting Mentors Online:\n" + llDumpList2String( onlineMentors , "\n" )
,<0.2,1.0,0.2>,1 );
integer nOnline = llGetListLength( onlineMentors );
if ( nOnline > 1 )
llOwnerSay("There are " + (string)nOnline + " scripting mentors online: "+
llDumpList2String(
llList2List(onlineMentors,0,nOnline - 2), ", " )
+ ", and " + llList2String( onlineMentors, nOnline - 1) );
else if ( nOnline == 1 )
llOwnerSay("Only one scripting mentor is online, "
+ llList2String(onlineMentors, 0 ));
else
llOwnerSay("Uh-oh, no scripting mentors are online! Try again later.");
}
}
}
}
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
06-24-2006 16:37
From: Dr Drebin
I pulled this out of the Library (Wiki) and it works... But it stores old data, and when I rez it I have to recompile/start running to get it to update correctly.

Easy (if a bit lazy) work-around to deal with it would be, have the script restart itself when rezzed:
CODE

on_rez( integer Parameter ) { llResetScript(); }

you can put the same thing in the touch() event, to have it refresh data when touched, or in the timer() event. Though not sure if having it continually update where there might not even be anyone around interested in the results... is that good idea. Doing it on touch seems more sensible since you are then fairly sure someone actually wants to know the outcome o.O;
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
06-24-2006 20:53
Heh, I liked making that script. I'll add the on_rez and touch updates to the code. I compiled the scanner script in my inventory, so it's already in a blank state when I rez something.