Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Storing data?

Bitt Toll
Registered User
Join date: 8 Jan 2007
Posts: 10
01-26-2007 10:59
What's the best way to store data? A script is limited to 16k, which you can use up pretty quickly. I thought about writing to a notecard, but it appears that the API only lets you read. I could post data to an external web site, but I was wondering if there was an easier way to have more than 16k of read/write data?

Thanks.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-26-2007 11:33
You can also use 'memory' scripts.
They are reasonably simple scripts that are used just to hold data for teh main script(s) and communicate via linked messages.

An extension to that are memory objects connected via email. An In world version of an external server if that makes sense.
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
01-26-2007 11:34
A common approach is to store your data in another script that is in the same prim (or a linked prim). Use llMessageLinked to set or retrieve your data.

For example, your primary script might list people's names and you want to store the list of people in another script. Your main script would look something like this:

CODE

touch_start(integer nDetected)
{
llMessageLinked(LINK_THIS,100,"",NULL_KEY);
}


..then in a new script in the same prim, so something like this...

CODE

list people;

link_message(integer sender_num, integer num, string str, key id)
{
integer i;
if(100==num)
{
for(i=llGetListLength(people) -1; i > -1; i--)
llSay(0,llList2String(people,i);
}
}


You could populate your other script by passing in a list of values...like this...
CODE

llMessageLinked(LINK_THIS,800,llList2CSV(people),NULL_KEY);



...and in your other script, populate a local variable like this....

CODE

link_message(integer sender_num, integer num, string str, key id)
{
if(800==num)
people=llCSV2List(str);
}


So it is sort of a game of ping pong between two scripts.

Repeat this pattern as many times as you like and you could end up with lots of usable memory.

-2fast
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
01-26-2007 17:16
Of course, if for whatever reason, you need to reset the scripts in an object, the memory will be wiped as well, memory scripts offer volatile memory.

Other options, depending on your needs, are to encode data into parameters of your object prims. Floats and integers can be concealed within texture offsets/rotations/scales, and you get a set of texture params to store within per each face. Of course, an object allowing modify would also allow someone to corrupt that data. Shortish strings/CSV's can be stored in the desription field of prims.

But, the best (not easiest) solution is to store the data on a server outside of SL. And use Http requests to read/write to it.

Ultimately, each method has pros and cons. One may be better than the others for a given situation, and vice-versa for a different situation.
Bitt Toll
Registered User
Join date: 8 Jan 2007
Posts: 10
01-28-2007 15:59
Great information. Thanks.

On a bit different note, is there a range limit on llMessageLinked?
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
01-28-2007 16:35
From: Bitt Toll
On a bit different note, is there a range limit on llMessageLinked?

No, only on linking.