Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Saving Data(e.g. form entry) in a script

Afir Zagato
fjnord
Join date: 2 Sep 2005
Posts: 4
10-13-2005 02:41
Hi, new to SL and LSL. I am curious as to how I can have a script save data from the user. My main worry is whether or not the data entered when the script is first run will remain say after the object is derezzed into inventory(take) and then rezzed later (location independent). Anyone have any tips for me on this?
_____________________
"A little nonsense now and then, is cherished by the wisest men."
-- Roald Dahl, (Willy Wonka) Charlie and the Chocolate Factory
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-13-2005 04:01
Yes, the script will continue running happily without resetting. I'm not sure it retains listeners and target handlers though, can someone confirm ?
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Afir Zagato
fjnord
Join date: 2 Sep 2005
Posts: 4
10-13-2005 04:50
Ok, the data is saved, but I only want the script to prompt the user (in this case the owner) once for the initial data entry. After that I plan to allow the user to interact with this script in other ways, but the initial prompt for data should only occur once for the owner and only the owner. Any tips on how to ensure this?
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-13-2005 05:07
Prompt in the state_entry() event of the default state, then move to another state once the data is in ;)
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Fenrir Reitveld
Crazy? Don't mind if I do
Join date: 20 Apr 2005
Posts: 459
10-13-2005 05:10
Jesrad: Yes, listens and such are retained, when a script is derezzed and rezzed.

Afir, I would do something like this...

CODE

integer gSomeGlobalVariable = 0 ;

state default
{
state_entry ()
{
// do first-time config info that sets gSomeGlobalVariable
state running ;
}
}

state running
{
state_entry ()
{
// do running stuff that refers to gSomeGlobalVariable
}
}


When the script is first started, it will be in the default state. Upon interacting with it, however you want, you just switch to the running state. The script will say in the running state as long as the script itself isn't deleted, restarted, or recompiled.

Keep in mind, some things don't follow through between states -- such as listens or sensors.

There is no way to currently save data permenantly inside the object or script itself. You can use an XML-RPC/email interface to send/receive the data from a script to an external store, but this is generally not a lightweight procedure.

It would be nice if prims had a small (small!) bit of space set aside for persistant property storage, or maybe the ability to create/write notecards... I fear none of this is easy to implement in the current LSL/SL system, otherwise we'd have seen it by now. ^_^
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-13-2005 05:15
You can store information in prims' description, for example.

Let's say you have an object made of one root "controller" prim, and a lot of child prims hidden inside that store and retreive the information. You can use:
- primitive parameters (texture info, color, cut/hollow settings, shape, bumpiness, etc...)
- prim name
- prim description
... to read/save data.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Spuds Milk
Registered User
Join date: 28 Sep 2004
Posts: 94
10-16-2005 12:14
note that if the program/sim/game crashes, all data will be lost. I know Lindon Labs does occasionally restart sims, I do not know if runstate/data is kept through those.

Personally, what I do is have a notecard in the object with default values, and instructions on how to modify it, then read the notecard as needed (and for the paranoid, use hard-coded defaults when non-sensical data is input)
Afir Zagato
fjnord
Join date: 2 Sep 2005
Posts: 4
10-18-2005 13:17
What if there were notecards put in the user's inventory the script could use to read/write from? Is this possible? Also, I guessing an input validation scheme could be implemented to verify the notecard data incase someone ambitious tinkers with it.

edit: After some quick thought and research, I think I may have stumbled upon something for my project. Correct me if I am wrong, but is it not possible to use multiple scripts in the same object to communicate changes in data that is queried from a user(say at character creation for an rpg) and then store this data in a holder script. Next, one has to get around the sim/script/game reset/crash problem so incorporating a timed XML-RPC/email call every (insert extended period of time or a save character option here) so that backups so to speak exist outside SL. Then I suppose would be the difficulty of restoring lost character data. Any more tips/discussion/advice?
_____________________
"A little nonsense now and then, is cherished by the wisest men."
-- Roald Dahl, (Willy Wonka) Charlie and the Chocolate Factory