Jump to content

How to save setting


Bo Grafta
 Share

You are about to reply to a thread that has been inactive for 1476 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have a visitor counter.

The counter also makes a graph.

How can I save the data, so that when I restart the data is still there.

I know I can store it in a notecard but I have seen ( protected) examples without a notecard.

Link to comment
Share on other sites

As for sim restart, I haven't had any troubles with my scripts saving data.  They just keep on running as if there was no restart. 

As for storing data in a note card, scripts are not allowed to do that.  

There are other more complicated ways of storing data that I don't understand, so I'll let the experts handle that!  :)  

  • Like 1
Link to comment
Share on other sites

Scripts do not reset when the region restarts, unless you have written them specifically to do that with CHANGED_REGION_START, so that's not a worry.

A script will always lose any internal memory when it's restarted, though, so you have to store valuable information somewhere else. You can save very small amounts of information in the Description fields of prims in the object's linkset.  That's handy for keeping key startup variables.  For storing more information, you need to send it to:

1. Another scripted object in world (your own "server" object)

2. A database outside of SL, like a Google spreadsheet.

3. A KVP record managed by your Experience, if your script is set to run under an Experience. 

4. Yourself as an IM or e-mail message, which you then handle manually (and with great frustration).

  • Like 2
Link to comment
Share on other sites

How much data needs to be saved?

If it's something like daily, or hourly, footfall – something that'll build into a huge number of items, then perhaps the key-value pairs feature of an experience might work. Otherwise you'll probably have to consider some form of external data storage, accessed by HTTP, perhaps something like Google Sheets (which is, by all accounts, rather fiddly to set up for this, but quite effective – I've not tried using it myself), or maybe a custom data storage service.

Another possibility is to create a dedicated data storage script; one that'll never be reset and which communicates with the main script via link messages to save and return values.

If you just need to store something like a cumulative total, or half a dozen or so values, then you could use the object's description or various object parameters like face colour settings.

Using a notecard for backup can be done by having the script chat out (or IM or email, like Rolig says, above) its stored data, which you then copy and paste into a notecard manually, and which can then be read back in by the script automatically.

Edited by KT Kingsley
  • Like 1
Link to comment
Share on other sites

I found a way to store and retrieve data:( a friend of mine told me)

Retrieve data: 

  state_entry()
    { 
       list setting=llGetPrimitiveParams([PRIM_TEXT]);
       CurrentLink= llList2Integer(setting, 0);
    }
    
    Store CurrentLink in this way:
     string text=(string)CurrentLink;                         
     llSetPrimitiveParams([PRIM_TEXT,text, ZERO_VECTOR,0.0 ]);  

Link to comment
Share on other sites

42 minutes ago, Bo Grafta said:

I found a way to store and retrieve data:( a friend of mine told me)

Retrieve data: 

  state_entry()
    { 
       list setting=llGetPrimitiveParams([PRIM_TEXT]);
       CurrentLink= llList2Integer(setting, 0);
    }
    
    Store CurrentLink in this way:
     string text=(string)CurrentLink;                         
     llSetPrimitiveParams([PRIM_TEXT,text, ZERO_VECTOR,0.0 ]);  

There's a caution I remember reading somewhere in the online documentation that floating text shouldn't be used to store data, because it is not reliable enough to store data over time.

  • Like 1
Link to comment
Share on other sites

Bo, when the data can fit in 127 bytes then a simple way is to store it in the Object Description field, a method Rolig mentioned above

llGetObjectDesc and llSetObjectDesc

http://wiki.secondlife.com/wiki/LlGetObjectDesc

a simple counter data store example

default
{
   touch_start(integer detected)
   {
       integer n = (integer)llGetObjectDesc();
       llSetObjectDesc((string)(++n));
   }
}

 

  • Like 1
Link to comment
Share on other sites

18 hours ago, sandi Mexicola said:

There's a caution I remember reading somewhere in the online documentation that floating text shouldn't be used to store data, because it is not reliable enough to store data over time.

I have yet to ever witness a set-text losing its value, granted i typically don't use them for that.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1476 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...