Queued Conditional Output: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Initial write-up.)
 
mNo edit summary
Line 11: Line 11:
{{param|what|Expects a string that contains the output; it is sent to the recipient as plain text, so HTML code works as intended.}}
{{param|what|Expects a string that contains the output; it is sent to the recipient as plain text, so HTML code works as intended.}}


===Notes:===
===Notes===
* When sending to a specific list of recipients, the output comes across as a whisper; that's just the way it is.
* 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.
* 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.
* 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're 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're know what you're doing and what to change).
<hr>'''onCampaignLoad'''
<hr>'''onCampaignLoad'''

Revision as of 03:10, 16 April 2009

 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're 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')]