|
ninjafoo Ng
Just me :)
Join date: 11 Feb 2006
Posts: 713
|
04-28-2006 02:05
Whats the best way to seperate data and script?
Mainly so variables dont get destroyed when the script is edited?
_____________________
FooRoo : clothes,bdsm,cages,houses & scripts
QAvimator (Linux, MacOS X & Windows) : http://qavimator.org/
|
|
Damanios Thetan
looking in
Join date: 6 Mar 2004
Posts: 992
|
04-28-2006 02:48
The best and most secure way is using your own external server for persistent data, and talk to it using xml-rpc and email (http requests in 1.9.1)
For smaller amounts of persistent data storage, you can write data in the prim itself. Usually usin llSetObjectName() (63 chars of data), llSetObjectDesc() (127 chars of data). And use linked prims for more data. There's the option to store even more persistent data in a prim, using llSetPrimitiveParams() to store data in all aspects of the geometry of a prim. But it's usually too cumbersome to be truely useful.
A last option is to use a data storage script and use linked messages to communicate with it. The disadvantage is that new copies of an object will not store the data of the original object. And script data is usually more 'vulnerable' to dataloss than prim attributes.
|
|
Starax Statosky
Unregistered User
Join date: 23 Dec 2003
Posts: 1,099
|
04-28-2006 04:52
Just a warning:
If the object is an attachment then there isn't a safe place for the data within the object itself. Attachments are restored to their last known unattached state when a sim crashes.
|
|
ninjafoo Ng
Just me :)
Join date: 11 Feb 2006
Posts: 713
|
04-28-2006 06:34
So basically there is no predefined 'standard' way of having a little persistant data unless you store it yourself out of world, or write a mess of hacks to hide it in a prim.
Its stuff like this thats making me enjoy LSL more and more.......
_____________________
FooRoo : clothes,bdsm,cages,houses & scripts
QAvimator (Linux, MacOS X & Windows) : http://qavimator.org/
|
|
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
|
04-28-2006 06:50
From: ninjafoo Ng Its stuff like this thats making me enjoy LSL more and more.......
Just be thankful you're not skinning, and having to deal with the massive shortcomings of the UV maps.
|
|
ninjafoo Ng
Just me :)
Join date: 11 Feb 2006
Posts: 713
|
04-28-2006 06:54
From: Nepenthes Ixchel Just be thankful you're not skinning, and having to deal with the massive shortcomings of the UV maps. Oh I am.......
_____________________
FooRoo : clothes,bdsm,cages,houses & scripts
QAvimator (Linux, MacOS X & Windows) : http://qavimator.org/
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
04-28-2006 08:38
From: ninjafoo Ng Whats the best way to seperate data and script?
Mainly so variables dont get destroyed when the script is edited? integer storage_prim; integer magic_number; string MAGIC_WORD="Squeamish Ossifrage"; integer save(string name, string value) { if(magic_number) llMessageLinked(storage_prim, magic_number, value, (key)name); else init(); return magic_number; }
integer request(string name) { if(magic_number) llMessageLinked(storage_prim, magic_number, name, (key)MAGIC_WORD); else init(); return magic_number; }
init() { llMessageLinked(LINK_SET, 0, "", (key)MAGIC_WORD); }
// user-provided callback routine, called when the pseudo-dataserver gets a value // back from the storage prim. my_set_value(string name,string value) { //...stuff like "if(name=="target") target = (key)value;" }
default { state_entry() { init(); } link_message(integer prim, integer num, string value, key id) { string name = (string)id; if(name == MAGIC_WORD) { storage_prim = prim; magic_number = num; return; } if(magic_number && num == magic_number) { my_set_value(name,value); return; } //... any other link_message foo... } } The implementation of the storage script(s) is an excersize left for the reader. In an attachment, for example, it/they would need to periodically save its state to another prim or to external storage using llEmail or something...
|