herolab.getInfo: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page Herolab.getInfo to herolab.getInfo: Converting page titles to lowercase)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
herolab.getInfo(id)
herolab.getInfo(tokenRef)
herolab.getInfo(id,field)
herolab.getInfo(id,field)
</source>
</syntaxhighlight>


'''Parameters'''
'''Parameters'''
{{param|id|The token id of the token to name, defaults to the Current Token.}}
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token to name, defaults to the Current Token.}}
{{param|field|A particular field from the metadata.}}
{{param|field|A particular field from the metadata.}}
{{Note|Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.}}


|example=
|example=
Get the Hero Lab data associated with the current token.
Get the Hero Lab data associated with the current token.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[herolab.getInfo()]
[herolab.getInfo()]
</source>
</syntaxhighlight>
Returns:
Returns:
<source lang="javascript" line>
<syntaxhighlight lang="javascript" line>
{
{
"summary": "Young red dragon - CE Large dragon",
"summary": "Young red dragon - CE Large dragon",
Line 38: Line 39:
"lastModified": "Fri Nov 02 16:28:33 CDT 2018",
"lastModified": "Fri Nov 02 16:28:33 CDT 2018",
"masterName": ""
"masterName": ""
}</source>
}</syntaxhighlight>
Get the status of the {{code|isMinion}} field from the Hero Lab data for the token named ''Orc 23''.
Get the status of the {{code|isMinion}} field from the Hero Lab data for the token named ''Orc 23''.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: isMinion = herolab.getInfo("Orc 23","isMinion")]
[r: isMinion = herolab.getInfo("Orc 23","isMinion")]
</source>
</syntaxhighlight>
Returns:
Returns:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
1
1
</source>
</syntaxhighlight>


|also=
|also=

Latest revision as of 01:34, 17 May 2024

herolab.getInfo() Function

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

Introduced in version 1.5
Get basic information about the Hero Lab data associated with this token. Returns a JSON object containing various metadata about the character.

Usage

herolab.getInfo(tokenRef)
herolab.getInfo(id,field)

Parameters

  • tokenRef - Either the token id or Token Name of the token to name, defaults to the Current Token.
  • field - A particular field from the metadata.
Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.

Example

Get the Hero Lab data associated with the current token.
[herolab.getInfo()]

Returns:

{
	"summary": "Young red dragon - CE Large dragon",
	"masterIndex": null,
	"isAlly": false,
	"images": ["asset://8799bd3b26bc614cf0a0f33675f5e77d", "asset://80b3ea5b47f5f1c7aec06a28219cde47"],
	"portfolioPath": "C:\\Users\\John\\Documents\\Pathfinder\\Giantslayer\\Episode 5 tokens\\",
	"playerName": "Joe",
	"isMinion": false,
	"portfolioFile": "C:\\Users\\John\\Documents\\Pathfinder\\Giantslayer\\Episode 5 tokens\\Part 3 GS 5.por",
	"gameSystem": "Pathfinder Roleplaying Game",
	"heroLabIndex": "11",
	"isDirty": true,
	"name": "Young Red Dragon #3",
	"lastModified": "Fri Nov 02 16:28:33 CDT 2018",
	"masterName": ""
}

Get the status of the isMinion field from the Hero Lab data for the token named Orc 23.

[r: isMinion = herolab.getInfo("Orc 23","isMinion")]

Returns:

1

See Also

Version Changes

  • 1.5 - Added to main MapTool build.