Difference between revisions of "External script memory"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '{{LSL Header|ml=3}}{{LSLC|}} {{LSL_Generic/gen-warning}} 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 pos...')
 
Line 1: Line 1:
{{LSL Header|ml=3}}{{LSLC|}}
{{LSL Header|ml=3}}{{LSLC|}}
{{LSL_Generic/gen-warning}}
{{LSL_Generic/gen-warning|info=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.
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.



Revision as of 00:20, 25 May 2010

Emblem-important-red.png General Warning!

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>