getLibProperty: Difference between revisions
m (Oops, it's "source" that should be replaced with "syntaxhighlight") |
No edit summary |
||
Line 16: | Line 16: | ||
For example, suppose a property named {{code|Weapons}} has a default value of "{{code|Shotgun, Pistol}}". | For example, suppose a property named {{code|Weapons}} has a default value of "{{code|Shotgun, Pistol}}". | ||
If you leave the value on the library token unchanged, it will appear to contain the value "{{code|Shotgun, Pistol}}" in places like the stat sheet, but this function will return an empty string. | If you leave the value on the library token unchanged, it will appear to contain the value "{{code|Shotgun, Pistol}}" in places like the stat sheet, but this function will return an empty string. | ||
< syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
[getLibProperty("Weapons", "lib:Compendium")] | [getLibProperty("Weapons", "lib:Compendium")] | ||
</syntaxhighlight > | </syntaxhighlight > | ||
Line 24: | Line 24: | ||
|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 | ||
< syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
[getLibProperty("init")] | [getLibProperty("init")] | ||
</syntaxhighlight > | </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 "{{code|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 "{{code|default}}". | ||
< syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
[result = getLibProperty("init")] | [result = getLibProperty("init")] | ||
[if(result == ""): result = "default" ] | [if(result == ""): result = "default" ] | ||
Line 35: | Line 35: | ||
To get the "init" [[Token:token property|token property]] from a [[Token:library token|library token]] called {{code|lib:Attacks}} use | To get the "init" [[Token:token property|token property]] from a [[Token:library token|library token]] called {{code|lib:Attacks}} use | ||
< syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
[getLibProperty("init", "lib:Attacks")] | [getLibProperty("init", "lib:Attacks")] | ||
</syntaxhighlight > | </syntaxhighlight > | ||
Line 43: | Line 43: | ||
This modification allows the namespace of the add-on library to be used where the {{code|Lib:}} token name would normally appear. For example, | This modification allows the namespace of the add-on library to be used where the {{code|Lib:}} token name would normally appear. For example, | ||
< syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
[h: getLibProperty("defaultStrength", "com.myname.mt.my-first-addon")] | [h: getLibProperty("defaultStrength", "com.myname.mt.my-first-addon")] | ||
</syntaxhighlight > | </syntaxhighlight > |
Revision as of 23:53, 29 February 2024
getLibProperty() Function
Usage
getLibProperty(name)
getLibProperty(name, lib)
Needs Clarification:
This block and its example seem to be outdated. Testing is required and this page corrected, if necessary.
For example, suppose a property named Weapons
has a default value of "Shotgun, Pistol
".
If you leave the value on the library token unchanged, it will appear to contain the value "Shotgun, Pistol
" in places like the stat sheet, but this function will return an empty string.
[getLibProperty("Weapons", "lib:Compendium")]
Returns an empty string.
It may help to review some relevant functions that apply to regular token properties, getProperty(), getPropertyDefault(), and resetProperty().
Examples
[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")]
Version Changes
Updated in 1.11:
MTscript functions for acting on library tokens have been modified to also work on Add-on libraries.
This modification allows the namespace of the add-on library to be used where the Lib:
token name would normally appear. For example,
[h: getLibProperty("defaultStrength", "com.myname.mt.my-first-addon")]