The following code can be added to your Roll20.net game to allow users to make Elemental Action rolls easily.
To use this functionality type into the chat window an exclamation mark followed by the element of the action and then a list of dice being rolled for the check. Using a capitalised D means that those dice are being rolled as element bending dice.
Example:

!fire 2d4 1D6

Code:


function republicRoll(msg, targets, numdice){
var output = "rolling: "+numdice+"<br>\r\n";
var regex = /([0-9]+)([dD])([0-9]+)/gi;
var result = [];
var totalwins = 0;
var totalfails = 0;
var loss = "";
while ( (result = regex.exec(numdice)) ) {
output += result[0];
var wins = 0;
var fails = 0;
for (i = 0; i < parseInt(result[1]); i++) {
if(result[2] == "D"){
var roll1 = randomInteger(parseInt(result[3]));
var roll2 = randomInteger(parseInt(result[3]));
var success = false;
if (targets.indexOf(roll1) > -1 || targets.indexOf(roll2) > -1){
wins++;
totalwins++;
}
if (targets.indexOf(roll1) <= -1 || !targets.indexOf(roll2) <= -1){
fails++;
}
if (targets.indexOf(roll1) > -1){
output += ", (<strong>"+roll1.toString()+"</strong>/";
}else{
output += ", ("+roll1.toString()+"/";
}
if (targets.indexOf(roll2) > -1){
output += "<strong>"+roll2.toString()+"</strong>)";
}else{
output += ""+roll2.toString()+")";
}
}else{
var roll = randomInteger(parseInt(result[3]));
var success = false;
if (targets.indexOf(roll) > -1){
success = true;
}
if(success){
output += ", <strong>"+roll.toString()+"</strong>";
wins++;
totalwins++;
}else{
output += ", "+roll.toString();
fails++;
totalfails++;
}
}
}
if(fails >0){
loss += fails.toString()+"d"+result[3]+" ";
}
output += ": <span style='font-weight:bold;font-size:large'>"+wins.toString()+"</span><br>\r\n";
}
output += "<h3>SUCCESSES: <strong>"+totalwins.toString()+"</strong></h3>Losses: <span style='color:red'>"+loss+"</span>";
output = output.replace(/([0-9]+d4)/gi,'<span style="color:#E74C3C">$1</span>');
output = output.replace(/([0-9]+d6)/gi,'<span style="color:#27AE60">$1</span>');
output = output.replace(/([0-9]+d8)/gi,'<span style="color:#F1C40F">$1</span>');
output = output.replace(/([0-9]+d12)/gi,'<span style="color:#8E44AD">$1</span>');
output = output.replace(/([0-9]+d20)/gi,'<span style="color:#2980B9">$1</span>');
return '<p>'+output+'</p>';
}
on("chat:message", function(msg) {
var output = "";
if(msg.type == "api" && msg.content.indexOf("!fire ") !== -1) {
var numdice = msg.content.replace("!fire ", "");
sendChat(msg.who, republicRoll(msg,[1,2,3,11,12,13],numdice));
}

if(msg.type == "api" && msg.content.indexOf("!earth ") !== -1) {
var numdice = msg.content.replace("!earth ", "");
sendChat(msg.who, republicRoll(msg,[4,5,6,11,12,13],numdice));
}
if(msg.type == "api" && msg.content.indexOf("!air ") !== -1) {
var numdice = msg.content.replace("!air ", "");
sendChat(msg.who, republicRoll(msg,[4,5,6,7,8,9],numdice));
}
if(msg.type == "api" && msg.content.indexOf("!self ") !== -1) {
var numdice = msg.content.replace("!self ", "");
sendChat(msg.who, republicRoll(msg,[3,4,7,8,9,10,11,12],numdice));
}
if(msg.type == "api" && msg.content.indexOf("!water ") !== -1) {
var numdice = msg.content.replace("!water ", "");
sendChat(msg.who, republicRoll(msg,[4,5,6,9,10,11,12,13,14,15,16,17,18,19,20],numdice));
}
});