Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

New to this kind of thing, but want to learn. Is my script possible?

I've never done any scripting or coding before, but I'd like to start to learn how. I want to make a script that rolls up to 100 dice plus possibly a modifier, and compares it to a target number, and then rolls the succeses number of dice. Is that possible? Is it too hard for a total newbie. Please don't just post a script, I want to learn.
1376419103
Bill K.
Pro
Sheet Author
No, that sounds quite reasonable.  Really, using inline rolls, I think you could accomplish it without a script, using just the inline roll commands, though I'm not positive.  But all you really need to do is do your '/r 100d6>4' sort of syntax for the first part, save that value, then use that value to do the second part of the roll.  The real difficulty, honestly, will be learning the syntax so that you can use this as a command from the chat window.
1376419671

Edited 1376420287
  Hi Jarret, first welcome! It's always exciting to see a new face. As far as your script, it certainly it. Think of coding as something that goes along in steps. You will need to break your process down into steps, and then create the code. The first step is: How will it be initiated. Typically, and I am going to assume, is you want it to be a chat command. To handle chat commands you use this function: on("chat:message", function(msg) {  } This function runs every time a chat message is given. Inside the brackets you will put the work you want to be done. In this case, you first want to test to see if the command was given. Lets say you want to name your dice rolling JarretsRoll and the command you want to give it would be !JarretsRoll. Now you must test to see if it was given. if(msg.content.indefOf("!JarretsRoll") !== -1 && msg.type == "api") { } This code tests to make sure your command is present AND that it was an api command. (API commands are chat lines that begin with an exclamation point. Next, you can roll your dice. If you want it to be static (I will assume that is the case) you can just handle it in the API. You roll the dice by sending a Chat command: SendChat(msg.who, "/r 100d10")   This command will roll 100d10s, and then you can manipulate the results as you want. Obviously, as you stated you want to add a modifier and control how many dice you roll. I will add more in the next part.
I actually figured out how to do it with inline rolls, but I still think I'm going to try and learn.