Jump to content

storing data


Rhiannon Arkin
 Share

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

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

Recommended Posts

Hi

I saw a few huds that store data, user settings. How do they do that? We can't write into a notecard so I assume the data is kept somewhere in memory. And if i detach and re-attach the hud, doesn't it reset it's memory? 

Is setting up a external server /database still the most reliable option ? 

thanks for suggestions

R. 

 

Link to comment
Share on other sites

1 hour ago, Rhiannon Arkin said:

Hi

I saw a few huds that store data, user settings. How do they do that? We can't write into a notecard so I assume the data is kept somewhere in memory. And if i detach and re-attach the hud, doesn't it reset it's memory? 

Is setting up a external server /database still the most reliable option ? 

thanks for suggestions

R. 

 

Scripts only lose the contents of memory when reset, which they might be scripted to do on_rez (which happens when attached from inventory), or explicitly when attached, but they certainly don't need to be, so they can retain memory more or less indefinitely.

(I would observe, though, that attachments are somewhat less stable than other items, so I wouldn't choose a HUD to store the password to a bitcoin wallet or Cambridge Analytica's "destroyed" trove of purloined Facebook data.)

Anyway, how much data are we talking about? If it's megabytes or more, then yeah, you probably want to store it externally (especially if you intend for it to survive even if Second Life disappears). Otherwise it depends how and where the data is used, how fast it needs to be accessed, how often there are updates, etc. Depending on all those things, Experience persistent store in "key-value pairs" may be an option.

Edited by Qie Niangao
  • Like 3
Link to comment
Share on other sites

As far as I'm concerned, the best way for a HUD to store data, at least if it's something like a combat or other game-playing HUD that's only going to be needed in particular regions, is as key value pairs (KVP) as part of an Experience.

That way you can create, read and update data stored on  LL's own servers at no cost other than the premium membership of whoever owns the experience (which doesn't need to be whoever writes the scripts).   

That works only on regions/parcels where the Experience is allowed to run.   But within that constraint it's the best and most reliable method available.   I've used it a lot and thoroughly recommend it.

  • Like 4
Link to comment
Share on other sites

If the data needs to survive a reset then KVP storage in an experience is certainly the most reliable way, and the way I would also recommend.

Other ways that can survive a reset: 

  • Storage to an outside server, but that requires that you have a very strong server with good uptime
  • Corrade has a SQL database that you can store things in with IM or RegionSayTo to the bot. Needs good uptime too.
  • Storage to description is popular, but the data is mutable by anyone with mod rights, and it's also limited in the characters you can store
  • A database prim kept somewhere in world is another possibility, although cross region communications can be a pain
  • Notecard that can be read on reset - a pain for users, but simple and reliable
  • Like 4
Link to comment
Share on other sites

It's not necessary to reset scripts. Just initialize what's needed when it's needed.

If that seems too difficult use a 2nd script with the only task to read/write data. That's easy and there is no need ever reset this data script. (as long as you avoid heap/stack collisions of course)

For a grid wide storage I see 3 possibilities:

1. KVP storage in an experience - disadvantage: you need an experience. For a hud I think KVP is pretty useless.

2. Your own external server. Perfect solution but only for you not for others. Probably too much efforts.

3. You use a server-script in World. If you ever loose connection you need to link again by - having a backup server somewhere or kvp or the server is in a sim that you visit regularly or whatever. A minor annoyance.

  • Like 1
Link to comment
Share on other sites

Interesting solutions. Maybe having an external server is a good solution, but is also a lot of work to set up properly. I was mostly wondering how user settings and preferences can be managed. I hardly need huge amouts of data, so maybe all the other solutions are more valid. It's a mostly theoretical exploration for now. 

I'll see if i can experiment with experiences too. They are still a bit mysterious to me. 

Link to comment
Share on other sites

I've used google sheets to store data, and retrieve it ... not too hard to set up. (http)

what i wanna know is, why is there a key-value function, but it is ONLY

available to paying members...

trans = llCreateKeyValue("FOO", "BAR"); ( For this function to work, the script must be compiled into an Experience. )

( Experience keys are only available to Premium members.  )

... sure, you can code with it outside an experience, but it's usable only Inside one...

 

just seems odd that they limit such a powerful function to paying members Only...

 

 

 

Edited by Xiija
Link to comment
Share on other sites

Google sheets! Lol. Brilliant. 

Probably a lot easier to set up then actual mysql databases. I wonder if you have resources to share on how to access google sheets on that level. 

 

Found the info, they have a api for python. 

Edited by Rhiannon Arkin
Link to comment
Share on other sites

4 hours ago, Xiija said:

what i wanna know is, why is there a key-value function, but it is ONLY

available to paying members...

There are several possible answers.  The one I find most convincing is that when used improperly, Experiences have great potential for griefing.  Not so much with the KVP features, but certainly with all of the opportunities that scripters have for getting implicit permission to animate/force sit/attach/teleport/... residents. By limiting Experiences to Premium members, Linden Lab guarantees that they have a way to track bad guys in RL.  Remember, of course, that you, as a scripter, do not need to be a Premium member. You just need to be in a group owned by a Premium member and then designated as a creator in that group.

  • Like 2
Link to comment
Share on other sites

@Rhiannon

I'm tryin to remember it all heh... something like...

You create a google form, and a google spreadsheet, and link the two together,

so all form submissions go to the sheet.

Then change the form url ... from /edit  to /viewform  and check page source, to get entry for answer boxes.( f12 ... or right click &  inspect element)

To POST to the form/sheet you use something like this for your url string...( my form had 2 boxes, ... region name, and url of the sending prim)

string send =
      "https://docs.google.com/forms/d/e/1FAIpQLSfmFFNdHlOpvkXBU_AyPKj4ATjTJdS8iA2N3K2ervPNxNwE_A/formResponse?entry.1012667783="
         + region + "&entry.457815027=" + url + "&submit=Submit";

 ( notice the .... &entry.457815027= .... those keys come from looking at the page source / inspecting the answer box elements on the form webpage.)

when you want to GET the info from the linked google spreadsheet, your url looks something like this...

"https://docs.google.com/spreadsheets/d/1MNKwhVqK8U8urzTWa_q0YtlGnYVn7SnICZBylstR2KE/pubhtml?gid=653993593&single=true&gid=0&output=txt&range=H4";

( returns what is in cell H4 )

you can use normal google sheet formulas to shift the data on the sheet how you need it ...

hope this helps a bit?

 

p.s. i'm guessing this is NOT a secure way to store data?...not even sure about what perms to view/edit you need

   on your sheet & form :P

 

p.p.s. ( not sure if any can view these, but...)

the form I used...

sim servers google form

the google spreadsheet...

sim server responses google spreadsheet

 

 

Edited by Xiija
  • Like 3
Link to comment
Share on other sites

  • 10 months later...

I am wondering if it is also possible to change data in a google spreadsheet or only to store it?

One problem with the http_request method "GET" is that the length of the information that you can pass is limited. And the length is further reduced by the very long google spreadsheet urls. @Xiija you must have come very, very close to the limit of what can be transmitted with "GET" in your example.  😄

Just in the case that you want to look into a PHP/SQL database example, I have posted one a few years ago:

 

Link to comment
Share on other sites

So I got as far as being able to write to a sheet via a form as @Xiija explained above like this:

string URL = "<the link to the form>" + "it works" + "&submit=Submit";
     key httpkey=llHTTPRequest(URL, [] , "");

The text "it works" appears in the sheet. Great!

Now I would like to be able to read that cell from SL. Can anyone help?

Link to comment
Share on other sites

21 minutes ago, steph Arnott said:

Not sure why you believe that.

Maybe I just don't know how SL handles data. My impression was that a script can store lists, but if you want to edit the script, the data in the lists (unless it is all defined) will be lost. A simple example is a members list. You click on a prim to add yourself as a member. Your ID is stored. But if I want to edit the script now, the list will be reset. Is that not correct? I am by no means an expert in LSL.

Are there links you can provide that show how SL handles data?

Link to comment
Share on other sites

Just now, Jazmina Voom said:

Maybe I just don't know how SL handles data. My impression was that a script can store lists, but if you want to edit the script, the data in the lists (unless it is all defined) will be lost. A simple example is a members list. You click on a prim to add yourself as a member. Your ID is stored. But if I want to edit the script now, the list will be reset. Is that not correct? I am by no means an expert in LSL.

Are there links you can provide that show how SL handles data?

Well i use satalite scripts for memory storage if it is worth it. You can edit the main as much as you like. I also use 1kb block data dump for archive. Simply paste it back in block by block.

Link to comment
Share on other sites

1 hour ago, steph Arnott said:

1kb block data dump

How is this dump done? A script cannot write to a note card, right?

In general I am enjoying the idea of having a script in SL communicate with "the outside world". I think that is the thing that is making me want to dig into this, not necessarily any practical need.

Link to comment
Share on other sites

6 minutes ago, Jazmina Voom said:

How is this dump done? A script cannot write to a note card, right?

In general I am enjoying the idea of having a script in SL communicate with "the outside world". I think that is the thing that is making me want to dig into this, not necessarily any practical need.

If you want inworld outworld then proceed with that plan. I just do not want to pay extra for an external server usage. Plus the fact i create stuff that will still work even i am no longer. Main issue with an external server is it is only active while being paid for and i personally have an issue with that as customers paid for my products and are garranteed they will always function. A personal choice.

Edited by steph Arnott
Link to comment
Share on other sites

1 hour ago, Jazmina Voom said:

How is this dump done? A script cannot write to a note card, right?

In general I am enjoying the idea of having a script in SL communicate with "the outside world". I think that is the thing that is making me want to dig into this, not necessarily any practical need.

You have several options for data storage depending on your needs.

1. You could use scripts as they are. They store data in lists or variables perfectly fine and if you need to retrieve the data you could write in a simple llOwnerSay loop to output all of the information into local chat for you to copy and save.

2. You could use script slaves. This method is having a central "server" script, say on your sim with several smaller slave scripts. The server script receives information sent to it and then send it on to the slave scripts to be stored. You would keep a check in each slave script making sure that memory usage doesn't exceed a certain amount. If it does, lets say in slave script 1, then slave script 1 would send the data on to slave script 2 to be stored.

3. Key pair values. This requires you to pay for premium and obtain an experience key but gives you access to key pair data storage which is....basically....access to database storage using in world functions such as llCreateKeyValue(), llReadKeyValue() etc etc

4. An external database. This requires paying for web hosting but allows you to store your data outside of SL in say an SQL database. Web hosting isn't expensive, my host with Xisto costs me 2 dollars a month and suits all my needs. If you are savvy enough you can actually create the database on your own computer and host the data there but for 2 dollars a month....paying for hosting is simpler.

5. Storage in google doc tables. This isn't really all that secure and is slower than other methods but useful non the less.

You are right to explore these options. Data storage is something that comes in very handy depending on the project you are doing. Each one of these has their advantages and disadvantages. For example, using an external database allows you to see and modify the data, if needs be, quite easily but requires you to pay for hosting and usually a web address. Where as using key pair values doesn't give you access to a readable database and requires you to script a way to look up, retrieve and modify specific key values BUT allows you to keep all of your code and storage in world and is very fast and effective. Google docs is simple and effective but slow and not all that secure...etc etc.

Your best bet is to just play around with the different methods and see which ones you feel are right for you. Even if you never end up using any of them its good to have the knowledge of how to do it in your toolkit incase you ever need to in the future.

Link to comment
Share on other sites

Thanks for the detailed reply @chibiusa Ling

I really like the idea of being able to store data outside SL to be written and read by scripts. Speed and security are not important as the data would not be sensitive. I don't feel like paying for premium membership or hosting a DB as I am just playing around at the moment. So Google docs seems like the way to go.

Now I just need to figure out how to GET the data.... I'll keep looking and post back here when I find the answer.

Link to comment
Share on other sites

One thing that I found very helpful as a content creator with external data was that I can analyse the usage of an item. Is the product used one time and the forgotten? Are all the functions used or only some? How long does a customer use a product? For me as a game creator it is especially valuable to see at what point a player might get frustrated and stops playing my product. I have learned a lot by looking at the data. All of this is perfectly possible with google spreadsheets. I have never used experience keys but I doubt that you can as easily access aggregated information.

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 519 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...