Queued Conditional Output

From RPTools Wiki
Jump to navigation Jump to search

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

Requires MapTool 1.3b55
The following is a user defined function that allows you to queue output to various recipients. All of the queued output is then displayed to the intended recipient/s after the completion of the current macro.


outputTo(who, what)


  • who - Expects a string containing the recipient/s; this string can be 'self', 'gm', 'gm-self', or a JSON array of player names(e.g. '["Bob","Joe"]').
  • what - Expects a string that contains the output; it is sent to the recipient as plain text, so HTML code works as intended.


  • When sending to a specific list of recipients, the output comes across as a whisper; that's just the way it is.
  • Currently there is no error checking, if you want/need error checking, it shouldn't be hard to implement.
  • There is theoretically no limit to the amount of outputs you can queue, but like any software your hardware will impose its own limits.


Place the following macros all on the same library token(or on different library tokens if you know what you're doing and what to change).


[defineFunction('outputTo', 'outputTo@this')]


[h: toSend = '{}']
[h: argTest = json.type(arg(0))]
[h, if(argTest=='ARRAY'), code:
    [h: toWho = 'list']
    [h: toSend = json.set(toSend, 'mlOutputList', arg(0))]
    [h: toWho = arg(0)]
[h: toSend = json.set(toSend, 'toSend', arg(1))]
[h: conditionalOutput = macroLinkText('conditionalOutput@this', toWho, toSend)]
[h: execLink(conditionalOutput, 1)]


[r: json.get(macro.args, 'toSend')]

See Also

macroLinkText, execLink