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

Inline rolls in a Whisper for API?

1389452793

Edited 1389453220
DXWarlock
Sheet Author
API Scripter
I cant seem to get inroll rolls to work in the API For example Im working on a blind roll script, modifying one I found on the forums here If I do this in chat: /w gm [[1d100<?{Percent|50}]] ?{Skill|Skillname} it works perfectly..and formats it how I want the API to return it. My Macro Im using to call it is: !br [[1d100<?{Percent|50}]] ?{Skill|Skillname} which then SHOULD get sent to the /w gm {text} in the APi below. But if I do that in API, It returns a result of '$0 Skillname' (with 0 saying 'rolling 0 = 0' if I hover over it) Doing log(msgFormula); spits out '"$[[0]] SkillName" My API code is below..anyone see what Im doing wrong that Im missing? on("chat:message", function(msg) { var cmdName = "!br "; var msgTxt = msg.content; var msgWho = msg.who; var msgFormula = msgTxt.slice(cmdName.length); if(msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) { log(msgFormula); sendChat(msgWho, "/w gm " + msgFormula); sendChat('System', "/w " + msgWho + " roll sent to GM"); }; });
A thought on what might be happening; Perhaps the macro is formulating what your inline roll comes out to before sending it to the API. I.E.: !br [[1d100<?{Percent|50}]] ?{Skill|Skillname} --> !br 0 ?{Skill|Skillname} -or- !br 1 ?{Skill|Skillname} Something you could try to do to fix it: on("chat:message", function(msg) { var cmdName = "!br "; var msgTxt = msg.content; var msgWho = msg.who; var msgFormula = msgTxt.split(" "); if(msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) { log(msgFormula); sendChat(msgWho, "/w gm [[" + msgFormula[1]) + "]] " + msgFormula[2]; sendChat('System', "/w " + msgWho + " roll sent to GM"); }; }); With an input of: !br 1d100<?{Percent|50} ?{Skill|Skillname}
1389589580

Edited 1389589627
Lithl
Pro
Sheet Author
API Scripter
The results of inline rolls are stored in msg.inlinerolls . There's a fair bit of information available in the inlinerolls object (it's the same information as msg.content when msg.type == "rollresult"), so you should probably check it out in the console to see what's available and what you need. The original roll text is stored there as well, so if nothing else you could send a whisper to the GM and reconstruct the roll if you wanted.
1389634410

Edited 1389634926
DXWarlock
Sheet Author
API Scripter
Thanks guys I used Alan's suggestion, as the inlinerolls option I cant figure out yet :P maybe its just me but the wikis API documentation doesn't seem to get very specific on usages of callbacks, just tells what they are so the inline alludes me on how to use it..haha