addToInitiative: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function addToInitiative== Adds all the current token to the initiative panel. ===Usage=== <source lang="mtmacro" line> [h: addToInitiative()] </source>)
 
No edit summary
 
(25 intermediate revisions by 8 users not shown)
Line 1: Line 1:
==Function addToInitiative==
{{Languages|addToInitiative}}{{stub}}
{{MacroFunction
|name=addToInitiative
|description=Adds the [[Current Token]] to the [[Introduction to Initiative|initiative panel]].  Additional parameters allow you to specify the token and an initiative value.


Adds all the current token to the initiative panel.  
|usage=
===Usage===
<syntaxhighlight lang="mtmacro" line>
<source lang="mtmacro" line>
addToInitiative()
addToInitiative(AllowDuplicates)
addToInitiative(AllowDuplicates, value)
addToInitiative(AllowDuplicates, value, tokenRef)
addToInitiative(AllowDuplicates, value, tokenRef, mapRef)
</syntaxhighlight>
 
'''Parameters'''
{{param|AllowDuplicates|If false (default) then will not add the token if it is already in the initiative list.  If true (1) an additional entry will be added to the initiative list (so there could be multiple initiative entries for the same token).}}
{{param|value|The initiative value to set.  If included, the initiative will be set even if the token is already on the initiative list and duplicates are not allowed.}}
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token to add to the initiative.  Defaults to the [[Current Token]]. {{TrustedParameter}} }}
{{param|mapRef|The Name or ID of the map to find the token.  Defaults to the current map.}}
* {{code|return}} - Returns 1 if added to the initiative, 0 if did not.
{{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=
The following example shows how to add a [[Current Token]] to the [[Introduction to Initiative|initiative panel]], set its initiative and then sort the [[Introduction to Initiative|initiative panel]]. Normally you would not sort the [[Introduction to Initiative|initiative panel]] every time you add a [[Current Token]] but its done here to show you how it is done.
 
<syntaxhighlight lang="mtmacro" line>
[h: addToInitiative()]
[h: addToInitiative()]
</source>
[h: setInitiative(1d20)]
[h: sortInitiative()]
</syntaxhighlight>
 
|also=
[[setInitiative | setInitiative()]] [[addAllPCsToInitiative | addAllPCsToInitiative()]] [[addAllToInitiative | addAllToInitiative()]]
 
|changes=
{{change|1.5.7|Added {{code|id}} and {{code|mapname}} parameter options.}}
 
}}
[[Category:Initiative Function]]
{{Languages|addToInitiative}}

Latest revision as of 23:59, 11 May 2024

Languages:  English  • 日本語

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.

addToInitiative() Function

Adds the Current Token to the initiative panel. Additional parameters allow you to specify the token and an initiative value.

Usage

addToInitiative()
addToInitiative(AllowDuplicates)
addToInitiative(AllowDuplicates, value)
addToInitiative(AllowDuplicates, value, tokenRef)
addToInitiative(AllowDuplicates, value, tokenRef, mapRef)

Parameters

  • AllowDuplicates - If false (default) then will not add the token if it is already in the initiative list. If true (1) an additional entry will be added to the initiative list (so there could be multiple initiative entries for the same token).
  • value - The initiative value to set. If included, the initiative will be set even if the token is already on the initiative list and duplicates are not allowed.
  • tokenRef - Either the token id or Token Name of the token to add to the initiative. Defaults to the Current Token.

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

  • mapRef - The Name or ID of the map to find the token. Defaults to the current map.
  • return - Returns 1 if added to the initiative, 0 if did not.
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

The following example shows how to add a Current Token to the initiative panel, set its initiative and then sort the initiative panel. Normally you would not sort the initiative panel every time you add a Current Token but its done here to show you how it is done.
[h: addToInitiative()]
[h: setInitiative(1d20)]
[h: sortInitiative()]

See Also

Version Changes

  • 1.5.7 - Added id and mapname parameter options.

Languages:  English  • 日本語