
So, I have been searching for the past few days, both on this forum and in Github and I have not been able to find the answer to a very specific question, so I am hoping posting this will help.
Background: I am what you might consider an advanced amateur with Roll20 and JavaScript. Most of my programming background comes from C++, so I am able to read and understand code, if not necessarily the best Java/Javascript specific tips and tricks.
Goal: I am trying to find a way, completely in an API script and without using chat, to be able to process complicated die rolls using the same format as what is used with the /roll chat function and inline rolls (I.e. /roll 4d6k3 to get the sum of the top 3 results of 4 d6s).
Reason: While I have found a way to send inline rolls to the chat and get the result back into variable for later use in the script, the process seems very clunky and causes lag with multiple players. I would like to cut out what I believe the major time crunch of passing/getting info from the chat window.
Example:
function diceprocessor (diceformula) {
var diceresult;
// something here that would take diceformula, as a String or an array as needed, process it to diceresult and returning diceresult as Integer or String, as needed.
return diceresult;
}
The best method I can think of right now is parsing diceformula, character by character and use a loop of case statements, but this feels like I am reinventing the wheel, since I know the chat system can already do this.
Any help would be appreciated.
- Dan
Background: I am what you might consider an advanced amateur with Roll20 and JavaScript. Most of my programming background comes from C++, so I am able to read and understand code, if not necessarily the best Java/Javascript specific tips and tricks.
Goal: I am trying to find a way, completely in an API script and without using chat, to be able to process complicated die rolls using the same format as what is used with the /roll chat function and inline rolls (I.e. /roll 4d6k3 to get the sum of the top 3 results of 4 d6s).
Reason: While I have found a way to send inline rolls to the chat and get the result back into variable for later use in the script, the process seems very clunky and causes lag with multiple players. I would like to cut out what I believe the major time crunch of passing/getting info from the chat window.
Example:
function diceprocessor (diceformula) {
var diceresult;
// something here that would take diceformula, as a String or an array as needed, process it to diceresult and returning diceresult as Integer or String, as needed.
return diceresult;
}
The best method I can think of right now is parsing diceformula, character by character and use a loop of case statements, but this feels like I am reinventing the wheel, since I know the chat system can already do this.
Any help would be appreciated.
- Dan