getPC: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==Function getPCs==
==Function getPC==
{{TrustedOnlyFunction}}
{{TrustedOnlyFunction}}


Line 9: Line 9:


<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: macros = getPCs()]
[h: macros = getPC()]
[h: macros = getPCs(delim)]
[h: macros = getPC(delim)]
</source>
</source>
delim is the delimiter used to separate the values in the  [[Macros:string list|string list]] which defaults to ',' if not specified.
delim is the delimiter used to separate the values in the  [[Macros:string list|string list]] which defaults to ',' if not specified.
Line 18: Line 18:
To display the ids of all of the [[Token:PC token|PC token]]s on the current [[Map:map|map]] use.
To display the ids of all of the [[Token:PC token|PC token]]s on the current [[Map:map|map]] use.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: ids = getPCs()]
[h: ids = getPC()]
[foreach(id, ids, "<br>"): id]
[foreach(id, ids, "<br>"): id]
</source>
</source>

Revision as of 19:54, 18 January 2009

Function getPC

This function can only be called from a trusted macro


Returns a list containing the ids of the PC tokens on the current map. The type of the value returned depends on the delimiter parameter.

  • If the delimiter is not specified then a string list is returned with the default value of ',' is used.
  • If the delimiter "json" then a json array is returned. (as of MapTool 1.3b49)
  • Otherwise a string list is returned with the delimiter passed in.
[h: macros = getPC()]
[h: macros = getPC(delim)]

delim is the delimiter used to separate the values in the string list which defaults to ',' if not specified.


Examples

To display the ids of all of the PC tokens on the current map use.

[h: ids = getPC()]
[foreach(id, ids, "<br>"): id]