Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

~What am I doing wrong?~

Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
01-06-2007 16:54
This script returms 3 random numbers...can anyone tell me what is wrong, and how to fix it? I am trying to make an age detector (in days).
From: someone

default
{
on_rez(integer x)
{
llResetScript();
}
state_entry()
{
}

touch_start(integer total_number)
{
string datestring = llRequestAgentData(llDetectedKey(0), DATA_BORN);

list date_elements = llParseString2List( datestring, ["-"], [] ) ;
integer year = (integer)llList2String( date_elements, 0 ) ;
integer month = (integer)llList2String( date_elements, 1 ) ;
integer day = (integer)llList2String( date_elements, 2 ) ;
llSay(0,"" + (string) year + " " + (string) month + " " + (string) day);
}
}


The script is not compelate, I'm gona turn the values into days later on, I just need to get the list to function right now =-/
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
01-06-2007 17:21
At the moment not even the default "Hello, Avatar" script is doing rational things. In the mess of random state switching and out-of-order and sometimes-a-minute-late llSay's I got your script to give me a datestring that looked like this:

7b4206a4-49e6-ac1c-3b24-dd171beb0ae6

Very much different each time, so I don't think it's working.

Edit:

Use a dataserver event. Here, straight from the wiki:

default
{
touch_start(integer num_detected)
{
llRequestAgentData(llDetectedKey(0), DATA_BORN); // request creation date
}
dataserver(key queryid, string data)
{
llSay(0, "You were born on: " + data);
}
}

works, but states and timing still wacky at the moment. It does give me the correctly-formatted datestring, though:

Object: You were born on: 2006-10-25
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
01-06-2007 17:26
Breakthrew..I have been able to turn the data into 3 usable numbers!
From: someone

default
{
state_entry()
{

}

touch_start(integer total_number)
{
llRequestAgentData(llDetectedKey(0), DATA_BORN); // request creation date
}
dataserver(key queryid, string data)
{
llSay(0, "You were born on: " + data);
list date_elements = llParseString2List( data, ["-"], [] ) ;
integer year = (integer)llList2String( date_elements, 0 ) ;
integer month = (integer)llList2String( date_elements, 1 ) ;
integer day = (integer)llList2String( date_elements, 2 ) ;
llSay(0,"" + (string) year + " " + (string) month + " " + (string) day);
}
}
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
01-06-2007 17:31
The wiki is your friend!

http://rpgstats.com/wiki/index.php?title=LlRequestAgentData


You need a data server event:

CODE

default
{

on_rez(integer x)
{
llResetScript();
}

state_entry()
{
}

touch_start(integer total_number)
{
string datestring = llRequestAgentData(llDetectedKey(0), DATA_BORN);
llOwnerSay (datestring);
}

dataserver(key queryid, string data)
{
list date_elements = llParseString2List( data, ["-"], [] ) ;
integer year = (integer)llList2String( date_elements, 0 ) ;
integer month = (integer)llList2String( date_elements, 1 ) ;
integer day = (integer)llList2String( date_elements, 2 ) ;
llSay(0,"" + (string) year + " " + (string) month + " " + (string) day);
llSay(0, "You were born on: " + data);
}

}
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
01-06-2007 17:34
From: Shippou Oud
Breakthrew..I have been able to turn the data into 3 usable numbers!

Some posts worth checking out here:
/15/a2/72795/1.html
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
01-06-2007 18:03
I now have the script to do what I want it to do, spit out days..any easier way to do it?
From: someone

default
{
state_entry()
{

}

touch_start(integer total_number)
{
llRequestAgentData(llDetectedKey(0), DATA_BORN);
}
dataserver(key queryid, string data)
{

list birthday = llParseString2List( data, ["-"], [] ) ;
integer byear = (integer)llList2String( birthday, 0 ) ;
integer bmonth = (integer)llList2String( birthday, 1 ) ;
integer bday = (integer)llList2String( birthday, 2 ) ;
// Line Break
string ts = llGetDate();
list now = llParseString2List( ts, ["-"], [] ) ;
integer nyear = (integer)llList2String( now, 0 ) ;
integer nmonth = (integer)llList2String( now, 1 ) ;
integer nday = (integer)llList2String( now, 2 ) ;
integer fy = (nyear * 365) - (byear * 365);
float fm = (nmonth * 30.5) - (bmonth * 30.5);
integer fd = nday - bday;
float sage = fy + fm + fd;
integer age = (integer) sage;
llSay(0,"" + (string) age);

}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-07-2007 03:16
If you're interested in manipulating dates you may find these functions that I posted of interest: /15/4f/136005/1.html

Deriving and parsing the dates is still up to you but by converting to Astronomical Julian Dates you can then simply subtract one date from another.