Bo Grafta Posted April 7, 2020 Share Posted April 7, 2020 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 More sharing options...
sandi Mexicola Posted April 7, 2020 Share Posted April 7, 2020 What kind of restart do you mean? A sim restart or a script reset? 1 Link to comment Share on other sites More sharing options...
Bo Grafta Posted April 7, 2020 Author Share Posted April 7, 2020 Both, script and Sim restart Link to comment Share on other sites More sharing options...
sandi Mexicola Posted April 7, 2020 Share Posted April 7, 2020 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! 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 7, 2020 Share Posted April 7, 2020 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). 2 Link to comment Share on other sites More sharing options...
KT Kingsley Posted April 7, 2020 Share Posted April 7, 2020 (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 April 7, 2020 by KT Kingsley 1 Link to comment Share on other sites More sharing options...
Bo Grafta Posted April 9, 2020 Author Share Posted April 9, 2020 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 More sharing options...
sandi Mexicola Posted April 9, 2020 Share Posted April 9, 2020 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. 1 Link to comment Share on other sites More sharing options...
Bo Grafta Posted April 9, 2020 Author Share Posted April 9, 2020 Yes, the warning is there for a long time Link to comment Share on other sites More sharing options...
Mollymews Posted April 9, 2020 Share Posted April 9, 2020 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)); } } 1 Link to comment Share on other sites More sharing options...
Bo Grafta Posted April 10, 2020 Author Share Posted April 10, 2020 Yes, thats also a posibility. They use this with the door scripts Link to comment Share on other sites More sharing options...
Kyrah Abattoir Posted April 10, 2020 Share Posted April 10, 2020 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 More sharing options...
Recommended Posts
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