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

API Update 4/27 -- Adding support for Nested Inline Rolls, Quoted Whisper Targets, Error Tracking for unexpected token

April 27 (10 years ago)
Riley D.
Roll20 Team
NOTE: This update is currently only pushed to campaigns running API Scripts on the DEV SERVER. We'll move it to live after we make sure nothing important broke!

We've just pushed out an update to the API Server which brings the dice engine up to date with the new Nested Inline Rolls update which rolled out today. So this permits you to create rolls which include nested inline rolls on the API Server.

In addition, we've added support for quoting whisper targets, like so:

/w "Riley D." test

Just like you can already do on the client side.

Finally, I've added some additional error logging which will hopefully help us track down the Unexpected error "s"-type bugs which are happening. If you see that error now you may get some more info alongside it -- if so please let me know here. Thanks!
April 27 (10 years ago)
The Aaron
Pro
API Scripter
Yeah!!
April 29 (10 years ago)

Edited April 29 (10 years ago)
Just logged in this morning and encountered the following:
events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoException (net.js:904:11) at Server._listen2 (net.js:1023:19) at listen (net.js:1064:10) at Server.listen (net.js:1132:5) at Sandbox.start (/home/symbly/www/d20-api-server/sandcastle/lib/sandbox.js:35:15) at Object. (/home/symbly/www/d20-api-server/sandcastle/bin/sandcastle.js:11:9) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12)
Didn't even get the last-line for an inactive campaign which is usually 'API sandbox has shutdown due to inactivity'



But the specific player whisper is a great add!
Now this one was outright strange:
May 06 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter

Using the following function to generate a string prefix for a sendChat message:

function getWhisperTarget(to) {
    var whisper = '';
    
    if (to) {
        whisper = '/w "' + getObj('player', to).get('displayname') + '" ';
    }
    return whisper;
}

Attempting, for example, sendChat('System', getWhisperTarget(msg.playerid) + 'Test Message'); results in the following in the API console:

{"who":"error","type":"error","content":"Unable to find a player or character with name: \"brian\""}

Trace debugging confirms the name that I'm trying to whisper to is "Brian".

May 06 (10 years ago)
The Aaron
Pro
API Scripter
Interesting. Does it work if the name has a space in it?
May 06 (10 years ago)

Edited May 06 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter

Just changed my display name to "Brian S" and got:

{"who":"error","type":"error","content":"Unable to find a player or character with name: \"brian"}

Note the lack of a second escaped quote in the error message. Changed my display name to "Foo Bar" and got the same error about being unable to find "foo" (with only one escaped quote in the message).

May 06 (10 years ago)
The Aaron
Pro
API Scripter
Dev or prod?
May 07 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter
Production
May 07 (10 years ago)
The Aaron
Pro
API Scripter
NOTE: This update is currently only pushed to campaigns running API Scripts on the DEV SERVER
Try on dev?
May 07 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter
Derp derp. =)
May 07 (10 years ago)
The Aaron
Pro
API Scripter
Guess it worked then? =D I can't wait for that change to hit prod. I can't count the number of times that problem has gotten me.
Just ran into the same problem with api whispers eating the target name. Like to know when its fixed on production server. Thanx.
May 10 (10 years ago)
The Aaron
Pro
API Scripter
Specifically, you're using this construct (with the name in " ")?
sendChat('','/w "'+msg.who+'" some text');
That change works on Dev but is not yet released to Prod. I'm sure there will be a notice posted here when it is.
The leader looks something like this

"/w \"" + msg.target_name + "\" " + body

Also tried hard-coding the target name with no success. The string looks ok on log output. And it gets eaten by sendChat. But I'm on Prod. It's not important enough for me to switch to Dev right now.
May 11 (10 years ago)
The Aaron
Pro
API Scripter
Right. The quoted who is only on Dev currently, that's why it's not working for you.
So is the quoted who been pushed live yet? I'm having api issues with sending whispers now on live servers.
May 27 (9 years ago)
The Aaron
Roll20 Production Team
API Scripter
I'm pretty sure it has not.
I figured out my problem... I was being dumb, lol. Had the character set to All Players and not me specifically. So no whispers were getting through if sent to that character name. Doh.