Difference between revisions of "LlSetObjectDesc"

From Second Life Wiki
Jump to navigation Jump to search
m (grammar error fix again)
 
(31 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{Issues/VWR-437}}{{Issues/SVC-3429}}{{Issues/VWR-8761}}{{LSL_Function/prim-desc|set}}
|func=llSetObjectDesc
|func=llSetObjectDesc
|sort=SetObjectDesc
|func_id=271|func_sleep=0.0|func_energy=10.0
|func_id=271|func_sleep=0.0|func_energy=10.0
|func=llSetObjectDesc
|p1_type=string|p1_name=description
|p1_type=string|p1_name=desc
|func_footnote
|func_footnote
|func_desc=Sets the prims description
|func_desc=Sets the prims description
|return_text
|return_text
|spec
|spec
|caveats=*The object description is limited to 127 bytes, any string longer then that will be truncated. This truncation does not always happen when the attribute is set or read.
|caveats
|constants
|constants
|examples=<pre>
|examples=
//store the owner's name in the prim description
{{{!}} class="sortable" width="100%" {{Prettytable}}
touch_start(integer total_number)
{{!}}- {{Hl2}}
! '''Set this prim's description'''
! '''Set the root prim's description'''
{{!}}-
{{!!}}<syntaxhighlight lang="lsl2">
default
{
    state_entry()
     {
     {
        string temp;
         llSetObjectDesc("NEW PRIM DESCRIPTION");
 
        temp = llKey2Name(llGetOwner());
 
         llSetObjectDesc(temp);
     }
     }
 
}
</pre>
</syntaxhighlight>
{{!!}}
<syntaxhighlight lang="lsl2">
default
{
    state_entry()
    {
        llSetLinkPrimitiveParamsFast(LINK_ROOT,
            [PRIM_DESC, "NEW ROOT PRIM DESCRIPTION"]);
    }
}
</syntaxhighlight>
{{!}}}
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow||{{LSLG|llGetObjectDesc}}|Returns the object description.}}
{{LSL DefineRow||[[llGetObjectDesc]]|Gets the prim description.}}
{{LSL DefineRow||{{LSLG|llGetObjectName}}|Gets the object name.}}
{{LSL DefineRow||[[llGetObjectName]]|Gets the prim name.}}
{{LSL DefineRow||{{LSLG|llSetObjectName}}|Sets the object name.}}
{{LSL DefineRow||[[llSetObjectName]]|Sets the prim name.}}
|also_tests
|also_tests
|also_events
|also_events
|also_articles
|also_articles
|notes=TEMPORARY EXTRA MEMORY STORAGE IN RUNNING SCRIPTS
{{LSL DefineRow||}}
 
|notes=
At the current time, you can hold up to 8034 characters in a prim's description while a script is running.
* Object descriptions are often used to store data that needs to be protected from script resets (see, for example, [[Prim Attribute Overloading]]). However, descriptions are not immutable and can be tampered with by users or other scripts, either intentionally or accidentally, so this method should only be considered a last resort for data storage.
Once the script ends, whatever data is written into the description will be truncated to 127 - 255 characters.
** [[llLinksetDataWrite]] and associated functions are generally better suited for this purpose, because they allow for significantly more data storage and are much more secure against tampering.
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.
--[[User:Geuis Dassin|Geuis Dassin]] 6/16/07
 
<pre>
    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));
    }
</pre>
|cat1=Prim
|cat1=Prim
|cat2
|cat2

Latest revision as of 19:08, 5 January 2023

Summary

Function: llSetObjectDesc( string description );
0.0 Forced Delay
10.0 Energy

Sets the prims description

• string description

Caveats

  • The prim description is limited to 127 bytes; any string longer then that will be truncated. This truncation does not always happen when the attribute is set or read.
  • The pipe character '|' and the newline character '\n' are not legal in a prim's description. They will be replaced with '?'.[1]
  • Note that when people have "Hover Tips on All Objects" selected in the viewer's "View" menu, they'll see the object description pop-up for any object under their mouse pointer. For that reason, it is good practice to only set human-friendly information in the description, e.g. keys and such.
  • When an attached object is detached, changes made by script to the name and description (of the root prim) of the attachment will be lost. While the object is attached the name and description can be changed but it will not be reflected in inventory. This caveat does not apply to child prims.

Examples

Set this prim's description Set the root prim's description
default
{
    state_entry()
    {
        llSetObjectDesc("NEW PRIM DESCRIPTION");
    }
}
default
{
    state_entry()
    {
        llSetLinkPrimitiveParamsFast(LINK_ROOT,
            [PRIM_DESC, "NEW ROOT PRIM DESCRIPTION"]);
    }
}

Notes

  • Object descriptions are often used to store data that needs to be protected from script resets (see, for example, Prim Attribute Overloading). However, descriptions are not immutable and can be tampered with by users or other scripts, either intentionally or accidentally, so this method should only be considered a last resort for data storage.
    • llLinksetDataWrite and associated functions are generally better suited for this purpose, because they allow for significantly more data storage and are much more secure against tampering.

See Also

Functions

•  llGetObjectDesc Gets the prim description.
•  llGetObjectName Gets the prim name.
•  llSetObjectName Sets the prim name.

Articles

•  Limits SL limits and constrictions

Deep Notes

Footnotes

  1. ^ The pipe character historically has been used to separate fields in the serialized version of inventory. The field is not multi-line so the newline character holds no meaning in this context.

Signature

function void llSetObjectDesc( string description );