Table of Contents
User data objects are a way of embedding user defined data in Chunk
files. Each user data object type is implemented as a collection of Python
scripts, and an XML-based definition file that ties the scripts together.
These scripts are located in the resource tree under the folder
scripts
.
User data objects differ from entities in that they are immutable (i.e. their properties don't change), and that they are not propagated to other cells or clients. This makes them a lot lighter than entities.
A key feature of user data objects is their linkability. Entities are able to link to user data objects, and user data objects are able to link to other user data objects. This is achieved by including a UDO_REF property in the definition file for the user data object or entity that wishes to link to another user data object.
For more information about linking, please refer to Server Programming Guide's section User Data Object Linking With UDO_REF Properties.
For details on the definition of a user data object, which is shared between the server and the client, see the document Server Programming Guide's section Directory Structure for User Data Object Scripting → The User Data Object Definition File.
Each user data object is a Python script object (PyObject). Depending on the user data object type, it can exist in different parts of BigWorld, as listed below:
-
Client only
Client only user data objects are created by using the CLIENT domain in the Domain tag inside its definition file. Client-only user data objects should not have cell or base scripts
For an example of a client-only user data object, please refer to the CameraNode user data object, implemented in the
and the<res>
/scripts/client/CameraNode.py
files.<res>
/scripts/user_data_object_defs/CameraNode.def -
Server only
Server only user data objects are instantiated on the server only, and will be instantiated in the cell if its Domain tag is CELL, or in the base if the Domain tag is set to BASE.
For an example of a server user data object, please refer to the PatrolNode user data object, implemented in the
and the<res>
/scripts/cell/PatrolNode.py
files.<res>
/scripts/user_data_object_defs/PatrolNode.def
The client can access all client-only user data objects using the command:
>>> BigWorld.userDataObjects <WeakValueDictionary at 3075900908>
This will return a Python dictionary, using the user data object’s unique identifier as the key, and its PyObject representation as its value. The attributes and script methods of the user data object can be accessed using the standard dot syntax:
>>> patrolNode.patrolLinks [UserDataObject at 2358353012, UserDataObject at 2358383771]