getLibProperty: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page GetLibProperty to getLibProperty: Converting page titles to lowercase)
No edit summary
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
getLibProperty(name)
getLibProperty(name)
getLibProperty(name, lib)
getLibProperty(name, lib)
</source>
</syntaxhighlight>


'''Important Note'''
'''Important Note'''
As mentioned in the introduction, if the value of the property on the Token equals the default value, the function will return nothing! This means that if e.g. you set the default property to  
As mentioned in the introduction, if the value of the property on the Token equals the default value, the function will return nothing! This means that if e.g. you set the default property to  
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
Weapons : Shotgun, Pistol, Revolver
Weapons : Shotgun, Pistol, Revolver
</source>
</syntaxhighlight>
And you leave the e.g. the value on the token lib:Compendium unchanged, so it will also contain the value "Shotgun, Pistol, Revolver", then
And you leave the e.g. the value on the token lib:Compendium unchanged, so it will also contain the value "Shotgun, Pistol, Revolver", then
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[getLibProperty("Weapons", "lib:Compendium")]
[getLibProperty("Weapons", "lib:Compendium")]
</source>
</syntaxhighlight>
will return nothing!
will return nothing!


Line 26: Line 26:
|examples=
|examples=
To get the "init" [[Token:token property{{!}}token property]] from the [[Token:library token{{!}}library token]] that a macro is running from use
To get the "init" [[Token:token property{{!}}token property]] from the [[Token:library token{{!}}library token]] that a macro is running from use
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[getLibProperty("init")]
[getLibProperty("init")]
</source>
</syntaxhighlight>


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".
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>
<syntaxhighlight lang="mtmacro" line>
[result = getLibProperty("init")]
[result = getLibProperty("init")]
[IF(result == ""): result = "default" ]
[IF(result == ""): result = "default" ]
</source>
</syntaxhighlight>


To get the "init" [[Token:token property{{!}}token property]] from a [[Token:library token{{!}}library token]] called "lib:Attacks" use
To get the "init" [[Token:token property{{!}}token property]] from a [[Token:library token{{!}}library token]] called "lib:Attacks" use
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[getLibProperty("init", "lib:Attacks")]
[getLibProperty("init", "lib:Attacks")]
</source>
</syntaxhighlight>
}}
}}
[[Category:Token Library Function]][[Category:Property Function]]
[[Category:Token Library Function]][[Category:Property Function]]

Revision as of 18:37, 14 March 2023

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)

Important Note As mentioned in the introduction, if the value of the property on the Token equals the default value, the function will return nothing! This means that if e.g. you set the default property to

Weapons : Shotgun, Pistol, Revolver

And you leave the e.g. the value on the token lib:Compendium unchanged, so it will also contain the value "Shotgun, Pistol, Revolver", then

[getLibProperty("Weapons", "lib:Compendium")]

will return nothing!

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")]