Queued Conditional Output: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page Queued Conditional Output to queued Conditional Output: Converting page titles to lowercase)
m (Taustin moved page queued Conditional Output to Queued Conditional Output without leaving a redirect)
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:


===Usage===
===Usage===
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
outputTo(who, what)
outputTo(who, what)
</source>
</syntaxhighlight>
'''Parameters:'''
'''Parameters:'''
{{param|who|Expects a string containing the recipient/s; this string can be {{code|'self'}}, {{code|'gm'}}, {{code|'gm-self'}}, or a JSON array of player names(e.g. {{code|'["Bob","Joe"]')}}.}}
{{param|who|Expects a string containing the recipient/s; this string can be {{code|'self'}}, {{code|'gm'}}, {{code|'gm-self'}}, or a JSON array of player names(e.g. {{code|'["Bob","Joe"]')}}.}}
Line 19: Line 19:
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).
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).
<hr>'''onCampaignLoad'''
<hr>'''onCampaignLoad'''
<source lang="mtmacro">
<syntaxhighlight lang="mtmacro">
[defineFunction('outputTo', 'outputTo@this')]
[defineFunction('outputTo', 'outputTo@this')]
</source>
</syntaxhighlight>
<hr><br>
<hr><br>
<hr>'''outputTo'''
<hr>'''outputTo'''
<source lang="mtmacro">
<syntaxhighlight lang="mtmacro">
[h: toSend = '{}']
[h: toSend = '{}']
[h: argTest = json.type(arg(0))]
[h: argTest = json.type(arg(0))]
Line 37: Line 37:
[h: conditionalOutput = macroLinkText('conditionalOutput@this', toWho, toSend)]
[h: conditionalOutput = macroLinkText('conditionalOutput@this', toWho, toSend)]
[h: execLink(conditionalOutput, 1)]
[h: execLink(conditionalOutput, 1)]
</source>
</syntaxhighlight>
<hr><br>
<hr><br>
<hr>'''conditionalOutput'''
<hr>'''conditionalOutput'''
<source lang="mtmacro">
<syntaxhighlight lang="mtmacro">
[r: json.get(macro.args, 'toSend')]
[r: json.get(macro.args, 'toSend')]
</source>
</syntaxhighlight>
<hr>
<hr>
===See Also===
===See Also===

Latest revision as of 18:33, 2 May 2023

 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.

Usage

outputTo(who, what)

Parameters:

  • 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.

Notes

  • 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.

Macros

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).


onCampaignLoad

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



outputTo

[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)]



conditionalOutput

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

See Also

macroLinkText, execLink