GOM- and DOM-related functions

From HEWIKI
(Redirected from GOM-related functions)
Jump to: navigation, search

These are commonly used built-in functions which are used to manipulate the GOM (Game Object Model) and DOM (Data Object Model) information.

The functions do such things as creating and destroying nodes and prototypes; specifying, adding, and removing classes; viewing and modifying Associations, Enums, Fields, and some System nodes, etc. Since these are "built-in" functions, they can be used from either client or server without restriction.

Note: Because new functions are added all the time, this list may be out of date. For the current list of available external functions, see the _ExternalFunctions script on client or server, as appropriate.

Contents

Create Node From Class

function CreateNodeFromClass(classname as string) as noderef

Create a node from a specified class. A node can have any number of classes on it, though the first one it is declared as becomes its "base class." This is just like standard object oriented inheritance. Create Node From Class

Create Node With ID From Class and Create Node With ID From Prototype

These are client side functions. Care must be used when creating a node with a specified ID to avoid conflicts. Currently this is envisioned to be used to make client side nodes with IDs that match server side ones.

CreateNodeWithIdFromClass(nodeID as ID, className as String)

CreateNodeWithIdFromPrototype(nodeID as ID, prototypeName as String)


Create Node from Prototype

function CreateNodeFromPrototype(protoName as string) as noderef}

Create a node from a specified prototype. See Create Node From Prototype

Create Node From Node

function CreateNodeFromNode(node as NodeRef) as NodeRef

Exposed function which exists on both client and server. Takes the node that it is passed, and returns a copy of it. Note that this function does not copy the persisted state of the node that was passed in. If it is desired to create a persisted node, then use the function CreatePersistedNodeFromNode().


Create Persisted Node From Class

function CreatePersistedNodeFromClass(classname as string) as noderef

As above, but creates a persisted node (See Node Persistence for more)


Create Persisted Node from Prototype

function CreatePersistedNodeFromPrototype(protoName as string) as noderef

As above, but creates a persisted node (See Node Persistence for more)


Create Persisted Node from Node

function CreatePersistedNodeFromNode(node as noderef) as noderef

Server-side function which takes a node as an argument and returns a persisted copy of that node. (See Node Persistence for more)


IsPersistentNode

IsPersistentNode(n as NodeRef) as Boolean

This is a server-side function which looks at a particular node, and checks to see if it was created as a persistent node. If so, it returns TRUE. It is primarily used as a debugging function. For more information on persistence, please see the sections on Node Persistence and Node Creation.


Create Prototype From Node

function CreatePrototypeFromNode(node as NodeRef, prototypeName as String, description as String) as noderef

This is a client-side function which creates a prototype based on the node that it is passed. It is primarily used by the GUIEditor.


Get Prototype

function getPrototype(name as string) as noderef

This built-in function takes a prototype name, and returns the associated noderef.

Get Prototype Name

function getPrototypeName(n as noderef) as string

This built-in function name takes a node reference which is a prototype, and returns a string with the name of that prototype. If this function is given a noderef which is not a prototype, a script error results.

Get Prototype Description

function getPrototypeDescription(n as noderef) as string

This built-in function name takes a node reference which is a prototype, and returns a string with the description of that prototype. If the specified noderef is not a prototype, then a script error results.

Destroy Prototype

function DestroyPrototype(prototype as noderef)

This function takes a node reference which is a prototype, and deletes it. It also automatically removes it from the prototype organizer.


Glom a Class onto a Node

function glomClass(ClassName as string, target as noderef)

Add a class to an existing node. A node can have any number of classes, though it will have only one "base" class that is defined when the node is created. Please see the Data Types section for more information about adding classes to nodes.


Destroy a Node

function DestroyNode(n as noderef)

Delete the specified node. See Creating and Deleting Nodes

Remove a Class from a Node

function RemoveClassFromNode(className as string, n as noderef)

Will remove a class that has been added or "glommed" onto the node. The fields of that class will be removed from the node, unless they are still valid from other classes still on the node, in which case they will not be affected. A node's base class cannot be removed. Attempting to remove a node's base class, or one of the classes that it inherits from, will generate an error. Use the WHERE <noderef> IS EXACTLY <class> command to determine appropriate classes for removal.


Query Prototypes

function queryPrototypes( outList references list of noderef, archetype as string)

Currently, the only valid string for archetype is "GUICONTROL". Attempting to use any other type will generate a script error.

Get Primary Class

GetPrimaryClass(n as noderef) as string

This built-in function gets the name of the primary class of a node


Get Classes

function GetClasses(object as NodeRef) as List of String

Deprecated Use GetClassesOnNode() instead.

This function returns the names of the base class and any glommed classes of the specified object. The base class will be returned as the first element of the list. This function does *not* return any parent classes (use the next function for that).

Get Parent Classes

function GetParentClasses(classname as string) as List of String

This function returns a list with the names of all immediate parent classes of the specified class. It does not return the names of previous generations of classes. If it is desired to learn the names of previous generations, it will be necessary to set up a recursive loop to check them all.

Get Class Fields

function GetClassFields(Class as String) as List of String

This function returns a list with the names of all of the primary fields of the specified class. It does not return the names of fields which are only inherited from a parent class.


Get Field Type

function GetFieldType(field as String) as String

This function takes the name of a field, and returns a string with the data type of that field.


Get Class Archetype

function GetClassArchetype(className as String) as String

This function takes the name of a class, and returns a string with the name of that class's archetype. See the section on Archetypes for a list of allowable types.


Get Class Description

getClassDescription( className as String) as String

This function returns the class description text of the specified function

GetClassesOnNode

GetClassesOnNode(node as Node Ref) as List of String

This replaces GetClasses() which is deprecated. It returns a list of class names for the specified node. The first class in the list will always be the primary class of the node, which is to say, the class from which the node was instantiated. Other classes in the list will be the result of glomming those classes onto the node. This function does not work on prototype nodes.

GetClassesOnPrototype

GetClassesOnPrototype(prototype as Node Ref) as List of String

This works identically to GetClassesOnNode(), but works on prototype nodes

getPrimaryClassOnNode

getPrimaryClassOnNode(node as Node Ref) as String

This is a shortcut function to get the primary class of a node, as described under GetClassesOnNode().

getPrimaryClassOnPrototype

getPrimaryClassOnPrototype(prototype as Node Ref) as String

This works identically to GetPrimaryClassOnNode(), but works on prototype nodes.

GlomClassToPrototype

GlomClassToPrototype(className as String, node as Node Ref)

This works identically to GlomClass(), but works on prototypes. Note that prototype editing will only work in the development world, not test or live worlds.

RemoveClassFromPrototype

RemoveClassFromPrototype(className as String, node as Node Ref)

This works identically to RemoveClassFromNode(), but works on prototypes. Note that prototype editing will only work in the development world, not test or live worlds.

Check If Class Exists

ClassExists(name as string) as boolean

Both client and server external function. Takes a name of a class, and returns TRUE if the class name is valid.

Check If Field Exists

FieldExists(name as string) as boolean

Both client and server external function. Takes a name of a field, and returns TRUE if the field name is valid.

Deprecated Functions

These functions have been deprecated and should not be used:

function ReplacePrototypeFromNode(node as noderef, prototypeName as string, description as string) as noderef

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox