broadcast: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 34: Line 34:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: broadcast("Hello World", '["tim", "tom"]')]
[h: broadcast("Hello World", '["tim", "tom"]')]
</source><br />
*Executing the macro 'update()' located at 'lib:Token', for the token 'Dragon' on the client PC of 'Tim':
<source lang="mtmacro" line>
[h: link = macroLinkText("update@Lib:Token", "none", "", "Dragon")]
[h: broadcast(execLink(link), "tim")]
</source><br />
</source><br />

Revision as of 14:40, 15 December 2013

broadcast() Function

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

Introduced in version 1.3b77

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

This function lets send you a message directly to the chat area of another/all connected maptool clients. It does not display the senders name or token image in front of the message.

It lets send you a message either to all or a list of players - use the player names or the keyword "gm". As delimiter you can specify either a string list separator character or "json" if you specify the target list as json array. The big difference between a 'normal' chat message is: 1. if the message is part of a macro then the message is send even if the macro is aborted(after the broadcast). 2. the sender of the message is NOT displayed and 3. if you broadcast an execLink() then that macro is AUTOMATICALLY executed on the clients its broadcasted to, with the exception to the client that sends the message!

Usage

 broadcast(message, [targets], [delimiter])

Parameters

  • message - a message that is broadcasted to the users that are listed as parameters.
  • targets - are the user names (so not token names) but the names of the users that are logged in. "gm" is also a valid parameter to give. E.g.: "tim, tom, tarra". Defaults to all players (so if no parameter is given the message is send to all players).}}
  • delim - The delimiter used to separate the values in the String List that is returned, defaults to ",". If "json" is specified, a JSON array is returned instead of a String List.

|example=

  • Sending a message to all players:
[h: broadcast("Hello World")]


  • Sending a message to gm only:
[h: broadcast("Hello World", "gm")]


  • Sending a message to tim and tom only:
[h: broadcast("Hello World", "tim, tom")]


  • Using the json as delimiter:
[h: broadcast("Hello World", '["tim", "tom"]')]


  • Executing the macro 'update()' located at 'lib:Token', for the token 'Dragon' on the client PC of 'Tim':
[h: link = macroLinkText("update@Lib:Token", "none", "", "Dragon")]
[h: broadcast(execLink(link), "tim")]