Difference between revisions of "External script memory"

From Second Life Wiki
Jump to navigation Jump to search
m (Using a warning here is inappropriate)
(+cat)
Line 67: Line 67:


</lsl>
</lsl>
[[Category:LSL Memory]]

Revision as of 11:22, 16 January 2013

Emblem-important-yellow.png Note! Under Construction

More examples need to be added.

There is a few ways in LSL to store external memory for using later on in case of resetting the script or any of many possibilities of just variable storage just wont cut it, and this page is to show whats the possible ways in storing data.


One way of storing data for later use is llGetObjectDesc and llSetObjectDesc.

<lsl> string data; string username; default {

   state_entry()
   {
       data = llGetObjectDesc();
       if(llGetObjectDesc()){
           llSay(0,"Last Toucher was saved as "+llGetObjectDesc());
       }else{
           llSay(0,"No Data found");
       }
   }
   touch_start(integer total_number)
   {
       username = llDetectedName(0);
      llSetObjectDesc(username);
      llResetScript();
   }

} </lsl>


To create a Boolean constant you can use a method like so.

<lsl> //These functions should only be used if your script is not going to be using llSetText SetConstant(integer tof){

   if(tof == TRUE)
       llSetPrimitiveParams([ PRIM_TEXT, " ",<1,0,0>, 1.0 ]);
       if(tof == FALSE)
       llSetPrimitiveParams([ PRIM_TEXT, "",<1,0,0>, 1.0 ]);
   } 

integer GetConstant(){

  list params = llGetPrimitiveParams([PRIM_TEXT]);
      if (llList2String(params,0))
          return TRUE;
          return FALSE;

}

default {

   state_entry()
   {
       llSay(0,(string)GetConstant()); //First time should output 0, then once you click and it restarts, it will output 1
   }
   touch_start(integer total_number)
   {
       SetConstant(TRUE);
       llResetScript();
   }

}

</lsl>