getLibProperty: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
m (Cleanup text; add an example)
Line 4: Line 4:
|description=Returns the value of a [[Token:token property{{!}}token property]] from a [[Token:library token{{!}}library token]]. If the lib argument is not specified then the [[Token:token property{{!}}token property]] will be retrieved from the [[Token:library token{{!}}library token]] that the macro is currently running from.
|description=Returns the value of a [[Token:token property{{!}}token property]] from a [[Token:library token{{!}}library token]]. If the lib argument is not specified then the [[Token:token property{{!}}token property]] will be retrieved from the [[Token:library token{{!}}library token]] that the macro is currently running from.


Unlike {{func|getProperty}}, this function will not retrieve the default value of a campaign property. The property value on the lib must be entered manually and must be different from any default values (the use of which is discouraged on lib tokens).
Unlike {{func|getProperty}}, this function will not retrieve the default value of a campaign property. Default values are generally programmed as local variables in a macro, then overridden with the result of this function if this function returns a value.  An example is shown below.


|usage=
|usage=
Line 16: Line 16:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[getLibProperty("init")]
[getLibProperty("init")]
</source>
To get the "init" [[Token:token property{{!}}token property]] from the [[Token:library token{{!}}library token]] if the library token has such a property.  If not, use a default value of "default".
<source lang="mtmacro" line>
[result = getLibProperty("init")]
[IF(result == ""): result = "default" ]
</source>
</source>



Revision as of 23:40, 30 June 2009

getLibProperty() Function

Introduced in version 1.3b48
Returns the value of a token property from a library token. If the lib argument is not specified then the token property will be retrieved from the library token that the macro is currently running from. Unlike getProperty(), this function will not retrieve the default value of a campaign property. Default values are generally programmed as local variables in a macro, then overridden with the result of this function if this function returns a value. An example is shown below.

Usage

getLibProperty(name)
getLibProperty(name, lib)

Examples

To get the "init" token property from the library token that a macro is running from use.
[getLibProperty("init")]

To get the "init" token property from the library token if the library token has such a property. If not, use a default value of "default".

[result = getLibProperty("init")]
[IF(result == ""): result = "default" ]

To get the "init" token property from a library token called "lib:Attacks" use.

[getLibProperty("init", "lib:Attacks")]