broadcast: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=broadcast |trusted=true |version=1.3b77 |description= | |name=broadcast | ||
|trusted=true | |||
|version=1.3b77 | |||
|description= | |||
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. | 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. | ||
Line 10: | Line 10: | ||
|usage= | |usage= | ||
<source lang="mtmacro" line> broadcast(message, [targets], [delimiter]) </source> | <source lang="mtmacro" line> broadcast(message, [targets], [delimiter]) </source> | ||
[[Category:Miscellaneous Function]] | [[Category:Miscellaneous Function]] | ||
Line 35: | Line 35: | ||
[h: broadcast("Hello World", '["tim", "tom"]')] | [h: broadcast("Hello World", '["tim", "tom"]')] | ||
</source><br /> | </source><br /> | ||
*Executing the macro 'update()' located at 'lib:Token', for the token 'Dragon' on the | *Executing the macro 'update()' located at 'lib:Token', for the token 'Dragon' on the PC of user 'Tim': | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: link = macroLinkText("update@Lib:Token", "none", "", "Dragon")] | [h: link = macroLinkText("update@Lib:Token", "none", "", "Dragon")] | ||
[h: broadcast(execLink(link), "tim")] | [h: broadcast(execLink(link), "tim")] | ||
</source><br /> | </source><br /> | ||
|Using the Bag of Tricks= | |||
Now usually in a macro you would like to use the execution on user pc to happen for those users that own the token in context, or maybe you want to execute a macro on ALL clients but you have to figure out who the current 'executer' is and run the macro for that client separately as the execLink is only executed on remote clients. To make this a bit easier I've created a couple of function which are on the [http://forums.rptools.net/viewtopic.php?f=46&t=16066 Bag of Tricks (BoT)]. If you have the BoT installed then the following functions are available to you: | |||
====bot_message()==== | |||
*{{code|bot_message(0:message [, 1:headertxt, 2:color (bgcolor-txtcolor), 3:userList, 4:token, 5:target, 6:broadcast])}} | |||
Broadcasts a preformatted message to all users (default). The message consists out of a black (bg) and white (txt) header (default) and a delimited textbox below it, containing the message. When the message is left empty ('') only the header will be displayed. bot_message contains the following optional parameters (only message is required): | |||
{{param|message|The message displayed}} | |||
{{param|headerText|This defaults to: ''. The text in the header, note that the 'token' parameter is set in the header as well on the left side. E.g. when token is 'Wolf' and headerTxt is 'Attacks' the header will read 'Wolf Attacks'}} | |||
{{param|color|This defaults to 'black-white'. Here you can set the backgroundcolor-textcolor of the header. You can choose also to only set the backgroundcolor. Some examples: 'red', 'black-yellow', yellow-red'.}} | |||
{{param|userlist|Defaults to all(). Here you can set to whom the message should be send. You can either fill in a user name yourself (NOT TOKEN NAME!) e.g. 'Frank' or you can make use of one of the user functions defined here below, e.g. all(), gm(), ownergm().}} | |||
{{param|token|Defaults to ''. Here you can give the name of the token to which the message reflects. The effect is that the image and name of the token appears left in the header}} | |||
{{param|target|Defaults to ''. Here you can give the name of another token to which the message reflects. The effect is that the image of tha token appears right in the header}} | |||
{{param|broadcast|Defaults to 0 the message is NOT broadcasted but the entire structure is returned. This is usefull is you want to e.g. embed the result in another message; (1) (default) the message is immediately broadcasted}} | |||
''A couple examples Use:'' | |||
<source lang="mtmacro" line>[resultMsg = bot_message('Hello world', 'Header', 'black-white', bot_all(), 'Wolf', '', 0)]</source> | |||
<source lang="mtmacro" line>[bot_message("Hellow world")]</source> | |||
<source lang="mtmacro" line>[bot_message("this message is shown to gm only", "GM Only", "red-yellow", bot_gm())]</source> | |||
[[Image:Example_Message.jpg]] | |||
<source lang="mtmacro" line>[bot_message("this message is shown to all but gm", "The rest", "yellow-red", bot_ngm())]</source> | |||
<source lang="mtmacro" line>[bot_message(token.name+" Takes damage", "is attacked", "black", all(), "Troll", "Elf")]</source> | |||
<source lang="mtmacro" line> |
Revision as of 15:12, 15 December 2013
broadcast() Function
Note: This function can only be used in a Trusted Macro
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 PC of user 'Tim':
[h: link = macroLinkText("update@Lib:Token", "none", "", "Dragon")]
[h: broadcast(execLink(link), "tim")]
|Using the Bag of Tricks= Now usually in a macro you would like to use the execution on user pc to happen for those users that own the token in context, or maybe you want to execute a macro on ALL clients but you have to figure out who the current 'executer' is and run the macro for that client separately as the execLink is only executed on remote clients. To make this a bit easier I've created a couple of function which are on the Bag of Tricks (BoT). If you have the BoT installed then the following functions are available to you:
bot_message()
bot_message(0:message [, 1:headertxt, 2:color (bgcolor-txtcolor), 3:userList, 4:token, 5:target, 6:broadcast])
Broadcasts a preformatted message to all users (default). The message consists out of a black (bg) and white (txt) header (default) and a delimited textbox below it, containing the message. When the message is left empty () only the header will be displayed. bot_message contains the following optional parameters (only message is required):
message
- The message displayedheaderText
- This defaults to: . The text in the header, note that the 'token' parameter is set in the header as well on the left side. E.g. when token is 'Wolf' and headerTxt is 'Attacks' the header will read 'Wolf Attacks'color
- This defaults to 'black-white'. Here you can set the backgroundcolor-textcolor of the header. You can choose also to only set the backgroundcolor. Some examples: 'red', 'black-yellow', yellow-red'.userlist
- Defaults to all(). Here you can set to whom the message should be send. You can either fill in a user name yourself (NOT TOKEN NAME!) e.g. 'Frank' or you can make use of one of the user functions defined here below, e.g. all(), gm(), ownergm().token
- Defaults to . Here you can give the name of the token to which the message reflects. The effect is that the image and name of the token appears left in the headertarget
- Defaults to . Here you can give the name of another token to which the message reflects. The effect is that the image of tha token appears right in the headerbroadcast
- Defaults to 0 the message is NOT broadcasted but the entire structure is returned. This is usefull is you want to e.g. embed the result in another message; (1) (default) the message is immediately broadcasted
A couple examples Use:
[resultMsg = bot_message('Hello world', 'Header', 'black-white', bot_all(), 'Wolf', '', 0)]
[bot_message("Hellow world")]
[bot_message("this message is shown to gm only", "GM Only", "red-yellow", bot_gm())]
[bot_message("this message is shown to all but gm", "The rest", "yellow-red", bot_ngm())]
[bot_message(token.name+" Takes damage", "is attacked", "black", all(), "Troll", "Elf")]
<source lang="mtmacro" line>