I'm using Brian's RealRollableTables API (with a tiny tweak or two) to roll these critical hit tables I have where you roll with modifiers. I also have critical fumble tables where you roll without modifiers, and I have those set up to output through macros and with Aaron's RecursiveTables script to the NPCActions template. I'd love to output the critical hit tables to the same template, but I THINK the only way to do that is to alter the script itself to output to the template. I don't know APIs pretty much at all, and haven't had much success. Here was my attempt. Can you tell me if this is possible? Original, with a slight tweak to alter the scripts name and because the script doesn't handle my roll modifiers in the text output well: sendChat('', '/r ' + roll, function(ops) {
var rollresult = JSON.parse(ops[0].content),
actualRoll = roll,
displayTotal = rollresult.total,
dieSize, tableItem, tableItemAvatar, tableItemIndex, tableItemName;
if (rollresult.resultType === 'M') {
// Math-only roll
dieSize = Math.min(parseInt(items.length - rollresult.total), 0);
actualRoll = '1d' + dieSize + ' + ' + roll;
displayTotal = (dieSize > 0 ? randomInteger(dieSize) : 0) + rollresult.total;
tableItemIndex = Math.max(Math.min(displayTotal - 1, items.length - 1), 0);
} else {
tableItemIndex = Math.max(Math.min(rollresult.total - 1, items.length - 1), 0);
}
tableItem = items[tableItemIndex];
tableItemAvatar = /*tableItem.get('avatar') ? '\n<img src="' + tableItem.get('avatar') + '" />' :*/ '';
//tableItemAvatar = tableItemAvatar.replace(/med|max/, 'thumb');
tableItemName = tableItem.get('name') ? '\n<span style="padding:3px;"><b>' +
tableItem.get('name') + '</b></span>' : '';
sendChat(getPlayerCharacterFrom(msg.who), 'Rolling ' + ' (' + displayTotal +
') on table "' + args[0] + '":' + tableItemAvatar + tableItemName);
});
}, My clumbsy attempt. sendChat('', '/r ' + roll, function(ops) {
var rollresult = JSON.parse(ops[0].content),
actualRoll = roll,
displayTotal = rollresult.total,
dieSize, tableItem, tableItemAvatar, tableItemIndex, tableItemName;
if (rollresult.resultType === 'M') {
// Math-only roll
dieSize = Math.min(parseInt(items.length - rollresult.total), 0);
actualRoll = '1d' + dieSize + ' + ' + roll;
displayTotal = (dieSize > 0 ? randomInteger(dieSize) : 0) + rollresult.total;
tableItemIndex = Math.max(Math.min(displayTotal - 1, items.length - 1), 0);
} else {
tableItemIndex = Math.max(Math.min(rollresult.total - 1, items.length - 1), 0);
}
tableItem = items[tableItemIndex];
tableItemAvatar = /*tableItem.get('avatar') ? '\n<img src="' + tableItem.get('avatar') + '" />' :*/ '';
//tableItemAvatar = tableItemAvatar.replace(/med|max/, 'thumb');
tableItemName = tableItem.get('name') ? '\n<span style="padding:3px;"><b>' +
tableItem.get('name') + '</b></span>' : '';
sendChat(getPlayerCharacterFrom(msg.who), "&{template:npcaction} {{name=Critical Hit Result}} {{description= [[tableItemAvatar + tableItemName }}");
});
},