After doing some more thinking about what I am looking to do and writing it down, I think I am going to approach it a little different. Instead of having a formatted whisper sent to the user, I will send a link that will open a frame with the information.
I start to work on it a little this morning but could not get the arg(s) to work.
Here is the code I have so far:
macro to create the link:
Code: Select all
[if( json.type( macro.args )!="OBJECT" ), code:{ <!-- Form data not submitted, (re-)draw the frame. -->
[h: playerList = getAllPlayerNames() ]
[H: thisMacro = getMacroName()+"@this" ] <!-- why have to change your code, just because you renamed your macro later? ;) -->
[frame("MKCDC15","width=200;height=300"):{
<html>
<head>
<title>Monster Knowledge Check DC15</title>
</head>
<body><form name ="MKCDC15" method="json" action='[r:macroLinkText( thisMacro, "none", "", currentToken() )]'><!-- the form is sent to this macro, output displayed to "none", no arguments, with the current token as focus. -->
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th>
Send To <small>([R:macroLink("Refresh Player List", thisMacro, "none")])</small>
</th>
</tr>
<tr>
<td>
[R: listFormat( playerList, "<select name='Player'>%list</select>", "<option value='%item'>%item</option>", "" )]
</td>
</tr>
<tr><td align="center">
<input type='submit' value='Send' ><input type='hidden' name='tName' value='[R: token.name]' >
</td></tr>
</table>
</html>
}]
[h:abort(0)]
};{
<!-- process form data submitted as a json object (in 'macro.args') -->
[H: targetName = json.get( macro.args, 'Player' )]<!-- contains the literal value, not an index. See how much fun html forms can be? -->
[h: arg = json.get(macro.args, 'tName')]
[h: testString = macroLink("Click This" , "displayMK@this", "self")]
[h: sendTo = json.fromList(targetName)]
[H: outputTo(sendTo, testString)] <!-- this is queued output: it will be sent to chat after this macro stops. -->
}]
Code: Select all
[h: tName = json.get(macro.arg, "tName")]
[frame("MK Display"): {
Display MK [r:tName]
}]