Difference between revisions of "Prim Attribute Overloading"

From Second Life Wiki
Jump to navigation Jump to search
(<lsl>)
Line 1: Line 1:
===Temporary Extra Memory Storage in Running Scripts===
===Temporary Extra Memory Storage in Running Scripts===
This functionality is broken as of Jan. 31, 2008 by server updates to repair [https://jira.secondlife.com/browse/SVC-674 SVC-674]
as well as a security vunerability. Current limits truncate the name and description fields to 63
and 127 bytes respectively, but may change in the future with the reopening of [https://jira.secondlife.com/browse/SVC-1394 SVC-1394] by LL staff.
But it is unlikely that storage will be more than 255 bytes per field, even if the limits are eased.
-- [[User:Void Singer|Void Singer]] 14:48, 19 February 2008 (PST)


At the current time, you can hold up to 8034 characters in a prim's description while a script is running. Once the script ends, whatever data is written into the description will be truncated to 127 - 255 characters. While this is not stable for long-term data storage like it used to be, at the present time it can be a useful trick for dealing with larger amounts of data in a script.
At the current time, you can hold up to 8034 characters in a prim's description while a script is running. Once the script ends, whatever data is written into the description will be truncated to 127 - 255 characters. While this is not stable for long-term data storage like it used to be, at the present time it can be a useful trick for dealing with larger amounts of data in a script.

Revision as of 15:48, 19 February 2008

Temporary Extra Memory Storage in Running Scripts

This functionality is broken as of Jan. 31, 2008 by server updates to repair SVC-674
as well as a security vunerability. Current limits truncate the name and description fields to 63
and 127 bytes respectively, but may change in the future with the reopening of SVC-1394 by LL staff.
But it is unlikely that storage will be more than 255 bytes per field, even if the limits are eased.
-- Void Singer 14:48, 19 February 2008 (PST)

At the current time, you can hold up to 8034 characters in a prim's description while a script is running. Once the script ends, whatever data is written into the description will be truncated to 127 - 255 characters. While this is not stable for long-term data storage like it used to be, at the present time it can be a useful trick for dealing with larger amounts of data in a script.

The following scenario is one that demonstrates this effect:

Increment a string up to 7127 characters and then write that to the prim desc using llSetObjectDesc().
Clear the variable, desc_data = "",
Read the data back into a different variable, string tmp; tmp = llGetObjectDesc();
Show the length of tmp, it shows 7127,

Test this with a timer(has been proven up to 4 minutes at least, then clear tmp = "";

Read in the data again using a 3rd variable, string new; new = llGetObjectDesc(); then it shows the same length, 7127.

Now, comment out the code that writes the initial data, and just read the description data with llGetObjectDesc(), it only comes back 255 as the string length,

So it seems, as long as you write and read the data within the same occurrence of the script, its fine. But if you try and read the data back in a different script iteration, its limited to 255.

The assumption is that when a script is finished running, the state of the prim description and name are being updated, cutting it off at 127 to 255 characters. --Geuis Dassin 6/16/07

<lsl>

   touch_start(integer total_number)
   {
       llOwnerSay("start");
       //127 characters long, fills up viewable space
       desc_data = "DO NOT EDIT THIS. DO NOT CLICK HERE" + 
                   ".............................................."+
                   "..............................................";
       //build the initial string, in this case the result will be 7127 characters long
       integer i=0;
       for(i=0;i<1500;i++){
   
           if(i % 100 == 0){
               //keep letting the user know the script is running.
               llOwnerSay((string)i);   
           }
           desc_data = (desc_data="") + desc_data + "aaaaa";
       }
       //show the length of the string before writing it
       llOwnerSay((string)llStringLength(desc_data));
       //##### COMMENT OUT THIS LINE DURING THE 2nd SCRIPT RUN TO PROVE THIS EXPERIMENT. 
       //##### THE DATA RETURNED WILL BE TRUNCATED AFTER THIS SCRIPT ENDS
       //write the string to the prim description
       llSetObjectDesc(desc_data);
       //empty the first variable
       desc_data = "";
       //read the data we just wrote back into a new variable
       string temp;
       temp = (temp="") + temp + llGetObjectDesc();
       //show the length
       llOwnerSay((string)llStringLength(temp));
       //sleep for X number of seconds, to prove that it holds state while the script is running.
       llSleep(10);
       llOwnerSay("slept 10");


       //read it in again into a 3rd variable
       string new;
       new = (new="") + new + llGetObjectDesc();
       //show the string length again.
       llOwnerSay((string)llStringLength(new));
   }

</lsl>