Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Determine how old an avatar is?

Christif Vaher
Registered User
Join date: 24 Jun 2008
Posts: 51
03-13-2009 10:13
Ok hold off on the flames, I am sure I have seen this information somewhere but repeated searches and I can't find exactly what I am looking for so help requested. What function do you use in LSL to find the age of an avatar ? For instance they touch a box and it gives their age in number of days.

Newbienag.lsl seems a bit clunky I as sure there was an easier method out there so any suggestions would be helpful. Thank you.
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
03-13-2009 10:21
A combination of llRequestAgentData (DATA_BORN)
http://lslwiki.net/lslwiki/wakka.php?wakka=llRequestAgentData

and

llGetDate
http://lslwiki.net/lslwiki/wakka.php?wakka=llGetDate

With some math.
_____________________
Tutorials for Sculpties using Blender!
Http://www.youtube.com/user/BlenderSL
Christif Vaher
Registered User
Join date: 24 Jun 2008
Posts: 51
03-13-2009 10:28
Thank you. Simplicity is always the hardest . I appreciate it.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
03-13-2009 10:32
use llRequestAgentData( key, DATA_BORN ) to find the date born. See:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=llRequestAgentData
When you have that date and the date to day it is merely calendar arithmetic the rest of the way:)
Here is a simple program that does not count leap years:
CODE
// SD Age detector Script by Dora Gustafson d.2008-02-10
// free for anybody to read, copy, modify, compile, use, rip apart, tramble on and flush

string nowtime;
integer dayAge;
string toucher;

integer month2days( integer month )
{
list monthCount = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 ];
return llList2Integer( monthCount, month-1 );
}

integer to_days( string calt )
{
// Keep it Simple!!! no leap year!
list yymmdd = llParseString2List( calt, ["-"], []); // YY-MM-DD
return 365*llList2Integer( yymmdd, 0) + month2days( llList2Integer( yymmdd, 1)) + llList2Integer( yymmdd, 2);
}

default
{
touch_start(integer num_detected)
{
string t = llGetTimestamp(); // for example: 2008-02-10T14:29:11.785886Z
list tNow = llParseString2List( t, ["T"], []); // split in calendar and clock parts
nowtime = llList2String( tNow, 0); // Calendar part
toucher = llDetectedName(0);
llRequestAgentData(llDetectedKey(0), DATA_BORN); // request creation date
}
dataserver(key queryid, string data)
{
// data in ISO 8601 format of YYYY-MM-DD.
dayAge = to_days( nowtime ) - to_days( data );
llSay(0, toucher + " is " + (string)dayAge + " days old" );
}
}
Take it from here :)
_____________________
From Studio Dora
Christif Vaher
Registered User
Join date: 24 Jun 2008
Posts: 51
03-13-2009 11:23
Excellent thank you !
ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
03-13-2009 14:20
lol I'm weird, but I use

CODE

llHTTPRequest( URL_RESIDENT + (string)avatar_key,[HTTP_METHOD,"GET"],"");

http_response(key req,integer stat, list met, string body)
{
string strbody = llGetSubString(body,llSubStringIndex(body,"Born"),llSubStringIndex(body,"</p>"));
}

then I just llSubString it to death and do the math lol..