Built-In Node Properties

From HEWIKI
Jump to: navigation, search

Please also see:

Overview

Nodes are strange and wonderful things. They can have many many different fields, with many different kinds of data in them. At least, that's how they are on a server.

During the optimization of the client, it was learned that it was more efficient to generate nodes on the client which weren't exactly the same as their counterparts on the server. These special client nodes are called "lightweight" nodes, usually of class hbnode. They have properties instead of fields. In most cases, for each field that exists on the server, there is a property of the same name, though there may be some fields which do not have a property equivalent. There are also a very few rare exceptions where the name of the property is different than the name of the related field.

Methods for accessing Property data via HSL have changed quite a bit during development. Originally it was not possible to access Properties at all. Then, there were special-use functions such as getProperty() and setProperty(). Now, however, properties can be accessed directly, with a distinct kind of syntax, depending on whether the script is running on the client or the server.

Important: Making a change to a field on the server will result in the identical change being made on the client. On the client, if a change is made to a property via HSL, that change does *not* get reflected on the server, but if the change is made via the Properties Panel, it *does* update the server's version of the data.


Example

Assuming that there is a node n with a field positionName. On the client side, this would be called the property positionName.

On the server, the proper syntax for changing the field would be like the following examples:

n.positionName = "a string"
nodeVar.stringVar = SubString(stringVar,1,2)

On the client, however, a script would use:

n["positionName"] = "a string"             // Note that the quotes are required
nodeVar["stringVar"] = SubString(stringVar,1,2)

Important: Just because a node is on the client, does not automatically mean that it is a lightweight node with properties. There can also exist temporary "normal" nodes which have their fields modified the same way as they would be on a server. If unsure what kind of node it is, check its class. Lightweight nodes are almost always of class hbnode.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox