|
Arachnid Baxter
Registered User
Join date: 8 Jan 2007
Posts: 44
|
01-11-2007 16:19
- When I pick up an object that's running a script, does the script get suspended and resume when I re-rez it, or does the script get reset when I re-rez it and start running from scratch?
- Is there any sort of persistent storage a script can write to and retrieve that survives being reset?
- Is it possible for a prim's/object's key to change without the scripts it's running being reset? Eg, is the key constant over the lifetime of the script?
- If a script requests permission from a user to do something (such as debit their account), does that permission have to be re-requested every time the script is reset? Eg, if you have something like the 'money trees' I see everywhere, and the sim goes down and comes back up, will they not work until the user that owns them logs back in and gives permission?
|
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
01-11-2007 16:35
Scripts are suspended in their current state on taking the object into inventory.
There is no built-in method for storing information like that, but many have come up with clever substitutions, like storing info in the name and description fields of child prims, or using e-mail or http to store outside of SL.
I believe the key changes on rez, but the script is not reset. You can keep up with the dynamic key using the on_rez() event.
Thankfully, scripts are not reset when the sim restarts, their state is saved across restarts, and scripts are "rolled back" to the last state save when a sim crashes, so it's not a big deal that when a script is reset, it has to ask for all permissions it needs again.
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
01-11-2007 16:37
From: Arachnid Baxter - When I pick up an object that's running a script, does the script get suspended and resume when I re-rez it, or does the script get reset when I re-rez it and start running from scratch? The script freezes while in inventory, and picks up where it left off once re-rezed... unless there is a function designed to reset the script when rezzed. Basically, a script isn't reset unless a function within the script resets it, or a user manually resets it. From: Arachnid Baxter - Is there any sort of persistent storage a script can write to and retrieve that survives being reset? There is nothing designed explicitly for storage. However, there are workarounds. You can write data to off-world storage such as your web server. You can also write data to various persistent properties of a prim such as the name/description fields or, depending on the data and prim, texture and prim params (integers and floats). From: Arachnid Baxter - Is it possible for a prim's/object's key to change without the scripts it's running being reset? Eg, is the key constant over the lifetime of the script? Yes & no, when an object is rezzed, it gets a new UUID/key. Also, I believe the key changes on teleports (the item is re-rezzed when you arrive at the teleport destination when using the built-in teleport funtion (not the scripted sit-teleport hack)). From: Arachnid Baxter - If a script requests permission from a user to do something (such as debit their account), does that permission have to be re-requested every time the script is reset? Eg, if you have something like the 'money trees' I see everywhere, and the sim goes down and comes back up, will they not work until the user that owns them logs back in and gives permission? Permissions only need to be requested when the script is reset. The script is not usually reset when a sim goes does... in that case, the script picks up where it left off when the sim is restarted.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-11-2007 16:43
EDIT : Seems Like Jillian and DoteDote beat me to the post ....
When taken into inventory a script is frozen, all variables retain their current value. The script doesnt even realsie it is no longer active.
You can choose to reset the script when you rez using the on_rez event handler, but it is not the default action, you must add it manually.
You can store small amounts of data in the prim name and description. Other than that you have the scripts memory and notecards. The draw back to notecards is they cannot be written to by LSL only read so its a manually updated system. There are also so called memory scripts, secondary scripts that purely hold data for the primary script to access via linked messages or other communication channels.
You can also use an external database via HTTP,RPC/XML.
Each time you rez a prim it is given a new key. I'm not 100% sure that this is true of NO COPY objects.
When a script is reset then the permissions are also reset, HOWEVER a sim going down WILL NOT generally cause scripts to reset, instead LL will reload from the last saved state and you may lose an hr or two of run time data but your script will not realise it.
|
|
Arachnid Baxter
Registered User
Join date: 8 Jan 2007
Posts: 44
|
01-11-2007 17:28
Okay, thanks. One of my concerns was assigning a unique identifier to a script so it can identify itself (and others) when contacting my external server in a reliable fashion. Since the script doesn't get reset during the lifetime of the object (unless I want it to, of course), I can just store it as a local variable.
|