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

[Help] Why does this code not work?

1420493316

Edited 1420493907
sendChat("DM", "/roll 1d100", function(ops){ sendChat("DM", ops[0]); }); On Dev server, return error: undefined:322 op.content = op.content.replace(abilreg, function(match) { ^ TypeError: Object has no method 'replace' at Object.d20.textchat.doChatInput (
1420495154

Edited 1420495249
Lithl
Pro
Sheet Author
API Scripter
ops[0] is the same kind of object as msg in on('chat:message', function(msg) {...}); . sendChat expects a string. In your example, ops[0].type would be 'rollresult', meaning ops[0].content is json roll data. So, if you want to for example send the final result to the chat, you could use JSON.parse(ops[0].content).total .
So much yet to learn. Thanks for the direction.
1420571960

Edited 1420574501
With much help and a lot of thinking, this is what I've come up with to handle this small piece of a much larger pie. It is working great. Thanks. I should add, the process inline rolls function is straight off the wiki: <a href="https://wiki.roll20.net/API:Cookbook#processInline" rel="nofollow">https://wiki.roll20.net/API:Cookbook#processInline</a>... To whomever wrote that,cheers! <a href="https://gist.github.com/limpinjezus/5eb527f261bb2d03c11a" rel="nofollow">https://gist.github.com/limpinjezus/5eb527f261bb2d03c11a</a>
1420574723
Lithl
Pro
Sheet Author
API Scripter
Michael said: I should add, the process inline rolls function is straight off the wiki: <a href="https://wiki.roll20.net/API:Cookbook#processInline" rel="nofollow">https://wiki.roll20.net/API:Cookbook#processInline</a>... To whomever wrote that,cheers! That would be Aaron who wrote the snippet. =)
1420617631
The Aaron
Pro
API Scripter
Awesome! Glad you found it useful! =D