User:Strife Onizuka/The State of State

From Second Life Wiki
Jump to navigation Jump to search

When it comes to scripting state can mean one of several things.

  • It can be a named grouping of events that can be designated to handle incoming events.
  • It can be the running status of the script.
  • It can be all of the script running information (memory, event queue, execution position, etc)
    • context:

Unless otherwise stated, 'state' will refer to the script running information.


Before we can talk about state, the structure of scripts needs to be expounded upon.


A script (as the user sees it) is an inventory item that once put into a prim can interact with the world the prim exists in. The important part of this definition for now is that it is an inventory item. All inventory items are made up of two parts: the underlying asset and the wrapper. The wrapper holds the inventory aspects of the item, for example the name, permissions, etc. The asset is the actual data. Assets in SL are read-only.


A script however is not a normal inventory item, besides the ordinary inventory aspect it also has an additional part. This extra part is the state which encompasses all execution information, pending events, etc.

Inventory Transfer

  • When a script is copied, it's state is not copied.
  • When a script is moved from one inventory to another, it's state is discarded.

While it makes some sense to let a script keep the contents of it's memory when it is transfered from one inventory into another. It does not make sense for it to keep it's entire state. A script might be in the middle of parsing an event, where it is manipulating the rest of the object, or sending messages to others scripts within the object. Events do not interupt, the script would have no practicle way of knowing when it resumed execution that it was no longer in the same prim.


   Scripts deactivated by llSetScriptState are reset when the region is reset, when they are taken into inventory and re-rezzed and when crossing sim boundaries.