Fair enough. :) It's in here . There's a lot of code in there, so the important steps are: 1. You have to actually roll the value through chat. I use the sender of that message as an easy way to catch it later, although you could possibly do it differently. For example, you might do this: sendChat("@accuracy", "[[1d100]]"); I also had a variable set up so that I knew to wait on other things until the result came in. If the steps listed above were going to be manual, you could skip this. But if you really wanted to code it all in one macro, you'd need to prevent the next line from executing until the result came, so something like this: macro_results["@accuracy"] = "WAITING"; (You'll need macro_results anyway to store and retrieve the results, you just might be able to skip setting it to "WAITING" at this point.) 2. Catch the result as a chat message: // Interrupts all chat messages to see if we've been waiting for them.
on("chat:message", function (msg)
{
if (msg.who.indexOf("@") == 0)
{
// ...
}
}); and you can probably significantly simplify what I did from here and just fill in the macro_results["@accuracy"] with the real result, via 3. Parsing out the chat message: // There's totally a better way, but this gets the total from an inline roll.
// It assumes that it's the only one on the line, but my code doesn't use this
// unless it is anyway. (I was having trouble with the better way.)
getInlineTotal = function(msg, i)
{
var total = "";
var roll = JSON.stringify(msg.inlinerolls);
if (!isnull(roll))
{
var pos = roll.lastIndexOf("total");
pos = roll.indexOf(":", pos);
var pos2 = roll.indexOf(",", pos);
total = roll.substring(pos + 1, pos2);
}
return total;
};
isnull = function(o) { return typeof o == 'undefined' || o == null || o.length == 0; };
4. If you're trying to automate all this, then have a function running on an interval that loops through macro_results and doesn't proceed until the result is != WAITING. Or put that code inside of the code that catches the chat, whichever is easiest for you. If you're running one macro after another manually, then just have any message with "@" look through your macro_results array and replace the values if it finds it. (Or use some flag that isn't already being used for something else in Roll20; probably that would be better) . Let me know if you have any questions! On another note, I'm seriously considering trying to update my script to handle this scenario, but probably not in the next few days.