Jump to content
Bo Grafta

How to save setting

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
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 ]);  

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...