getProperty: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Fixed use of wiki macro)
No edit summary
Line 5: Line 5:
|description=
|description=
Returns the value of a [[Token Property]] on a [[Token]].   
Returns the value of a [[Token Property]] on a [[Token]].   
If the [[Token Property]] is empty ({{code|NULL}}) or not defined, an empty string ({{code|""}}) is returned.
If the [[Token Property]] is empty ({{code|NULL}}) or not defined, an empty string ({{code|""}}) is returned. If you are referencing the literal name of the property (for instance, if you wish to get the property ''Constitution'' configured in Campaign Properties), enclose the property name in quotes. However, if you have a variable whose value is the name of the property, do not enclose the variable name in quotes.
 
|usage=
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
Line 20: Line 19:


|example=
|example=
Getting a property using the literal property name.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
The value of property 'Strength' is [r: getProperty("Strength")].
The value of property 'Strength' is [r: getProperty("Strength")].
Line 27: Line 27:
  The value of property 'Strength' is 18.
  The value of property 'Strength' is 18.


Getting a property using a variable.
<source lang="mtmacro" line>
[h:desiredProperty = "Constitution"]
The value of property 'Constitution' is [r: getProperty(desiredProperty)].
</source>
This will output the following if '''Constitution''' has the value '''12''':
  The value of property 'Constitution' is 12.
|also=
|also=
[[setProperty|setProperty()]],  
[[setProperty|setProperty()]],  

Revision as of 15:10, 15 January 2010

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
 This article needs: Examples of usage.

getProperty() Function

Introduced in version 1.3b48
Returns the value of a Token Property on a Token. If the Token Property is empty (NULL) or not defined, an empty string ("") is returned. If you are referencing the literal name of the property (for instance, if you wish to get the property Constitution configured in Campaign Properties), enclose the property name in quotes. However, if you have a variable whose value is the name of the property, do not enclose the variable name in quotes.

Usage

getProperty(property)
getProperty(property, id)

Parameter

  • property - The property that has its value returned.
  • id - The token id or name of the token that has its property value returned, defaults to the Current Token.

     Note: This parameter can only be used in a Trusted Macro

Example

Getting a property using the literal property name.
The value of property 'Strength' is [r: getProperty("Strength")].

This will output the following if Strength has the value 18:

The value of property 'Strength' is 18.

Getting a property using a variable.

[h:desiredProperty = "Constitution"]
The value of property 'Constitution' is [r: getProperty(desiredProperty)].

This will output the following if Constitution has the value 12:

The value of property 'Constitution' is 12.

See Also

Version Changes

  • 1.3b51 - Added id parameter option.
  • 1.3b51 - Changed to return the default value if the property has no value.