getLibProperty: Difference between revisions
m (Added references for add-on libraries; cleaned up grammer/formatting) |
m (Added reference to add-ons; cleanup of grammar/formatting) |
||
Line 11: | Line 11: | ||
getLibProperty(name, lib) | getLibProperty(name, lib) | ||
</source> | </source> | ||
{{Note|If the value of the property on the library token equals the default value, then MapTool will treat the property as though it were empty (because its content matches the default value that is used when the property is empty) and will return an empty string!}} | {{Note|{{Clarify|This block and its example seem to be outdated. Testing is required and this page corrected, if necessary.}} | ||
If the value of the property on the library token equals the default value, then MapTool will treat the property as though it were empty (because its content matches the default value that is used when the property is empty) and will return an empty string!}} | |||
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. | ||
Line 20: | Line 22: | ||
It may help to review some relevant functions that apply to regular token properties, {{func|getProperty}}, {{func|getPropertyDefault}}, and {{func|resetProperty}}. | It may help to review some relevant functions that apply to regular token properties, {{func|getProperty}}, {{func|getPropertyDefault}}, and {{func|resetProperty}}. | ||
|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 | ||
Line 37: | Line 38: | ||
[getLibProperty("init", "lib:Attacks")] | [getLibProperty("init", "lib:Attacks")] | ||
</source> | </source> | ||
|changes= | |||
'''Updated in 1.11:''' | '''Updated in 1.11:''' | ||
MTscript functions for acting on library tokens have been modified to also work on [[MTscript_functions_related_to_Add-on_libraries|Add-on libraries]]. | MTscript functions for acting on library tokens have been modified to also work on [[MTscript_functions_related_to_Add-on_libraries|Add-on libraries]]. |
Revision as of 03:12, 11 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")]