broadcast: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Updated with not-* target options.)
No edit summary
Line 7: Line 7:
Allows sending a message directly to the chat area of another/all connected MapTool clients. It does not display the sender's name or token image in front of the message.
Allows sending a message directly to the chat area of another/all connected MapTool clients. It does not display the sender's 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 {{code|"gm"}}. As delimiter you can specify either a string list separator character or {{code|"json"}} if you specify the target list as json array. The big differences compared to a normal chat message are:
Broadcast sends a message either to all or a list of players - use the player names or one or more of the keywords like {{code|"gm"}}. With the delimiter parameter you can specify either separator character for a string list or {{code|"json"}} to indicate the target list is a json array. The big differences compared to a normal chat message are:


#  if the message is part of a macro, then the message is sent even if the macro is aborted (after the broadcast),
#  if the message is part of a macro, then the message is sent even if the macro is aborted (after the broadcast),

Revision as of 13:34, 17 January 2020

broadcast() Function

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

Introduced in version 1.3b77
Allows sending a message directly to the chat area of another/all connected MapTool clients. It does not display the sender's name or token image in front of the message.

Broadcast sends a message either to all or a list of players - use the player names or one or more of the keywords like "gm". With the delimiter parameter you can specify either separator character for a string list or "json" to indicate the target list is a json array. The big differences compared to a normal chat message are:

  1. if the message is part of a macro, then the message is sent 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 it's broadcasted to, with the exception of 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 - a String list or JSON array of Player names, not Token names. Also recognizes: "gm", "gm-self", "self", "none", "all", "not-gm", "not-self", and "not-gm-self" as valid parameters. 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 given, defaults to ",". If "json" is specified, a JSON array is expected instead of a String List.

Examples

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

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

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

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

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

Version Changes

  • 1.5.5 - Added the gm-self, self, all, and none options to targets.
  • 1.5.7 - Added the not-gm-self, not-self, and not-gm options to targets.