Queued Conditional Output: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Taustin moved page queued Conditional Output to Queued Conditional Output without leaving a redirect) |
(No difference)
|
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')]