AddAssociation

From HEWIKI
Jump to: navigation, search

AddAssociation(source as noderef, association_type as string, target as noderef)

Arguments

<source> 
A node reference referring to the source node.
<association_type> 
A string representing the type of association to add. This must already have been created via the DOM (such as with the CAD command).
<target> 
A node reference referring to the target node that is being associated.


Description

This is a built-in function in HeroScript which creates an association between a source and target node reference. To remove the association, use Remove Association.

For more information, please see the section on Associations.

Example

To associate a sword as being "in" a backpack, the backpack would be the source node, the sword would be the target, and the association type would be "in".

public function Initialize()
 
  swordref as noderef = CreatePersistedNodeFromClass("thingie")       // Create sword node reference
  backpackref as noderef = CreatePersistedNodeFromClass("container")  // Create backpack node reference
 
  AddAssociation(me, "wearing", backpackref)              // Put the backpack on a player
  AddAssociation(me, "base_hard_association", backpackref) // Make a hard association so it saves
 
  AddAssociation(backpackref, "in", swordref)             // Put the sword in the backpack
  AddAssociation(backpackref, "base_hard_association", swordref) // Make a hard association so it saves
 
  MsgArea("Associations created.")
.
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox