token (roll option): Difference between revisions
m (Macros:Functions:token moved to token: Moving page out of Macros namespace.) |
m (Added the "see also" section to the template.) |
||
Line 29: | Line 29: | ||
:<tt>The healthbar of <b>Goblin 21</b> should be at 80%.</tt> | :<tt>The healthbar of <b>Goblin 21</b> should be at 80%.</tt> | ||
|also= | |||
[[Macros:Functions:currentToken|currentToken()]], [[Macros:Functions:switchToken|switchToken()]], | [[Macros:Functions:currentToken|currentToken()]], [[Macros:Functions:switchToken|switchToken()]], | ||
[[Macros:Functions:floor|floor()]]. | [[Macros:Functions:floor|floor()]]. | ||
}} |
Revision as of 01:22, 8 March 2009
token() Function
Note: This function can only be used in a Trusted Macro
Usage
[token(identifier): single_statement]
[token(identifier), code: {
statement1
statement2
}]
The identifier is the name of the token. The search first checks to see if the specified string is the Name of any token (i.e. matches token.name), then it checks GMName (i.e. matches token.gm_name), and last it checks the unique token id (this is a 32-character string generated by MapTool).
If there are multiple tokens with the same name, such as Goblin, then the GM Name field of the token should be unique so that it can be used to select tokens. Note that the getAllTokens() and related functions return a list of token ids.
Examples
[h, token("Goblin 21"): health = floor(100*HP/HPmax)]
The healthbar of <b>Gobling 21</b> should be at [r: health]%.
If Goblin 21 has 32 hit points and a maximum hit points of 40 (and these numbers are stored in HP and HPmax properties, respectively), the output produced will be:
- The healthbar of Goblin 21 should be at 80%.