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

Log a single backslash character to the API console?

Apologies if this has been asked before, but it seems like such a narrow/niche request that I can't seem to find it by searching. Here's what I'm running into... It seems the API console behaves a little differently to other consoles. I've tried a number of combinations to output a backslash character as a part of a larger string I am trying to send to the console, but I either get no backslashes, 2 or more backslashes. For instance, let's say I wanted to output: \m/ So far I have tried: const horns = '\m/'; log(horns);                     // produces: m/ log(String.raw`${horns}`;       // produces: \"m/\"" log(JSON.stringify(horns));     // produces: m/ If I try to escape the backslash, I get multiples: const horns = '\\m/'; // <-- two backslashes this time log(horns);                     // produces: \\m/ log(String.raw`${horns}`;       // produces: \"\\\\m/\"" log(JSON.stringify(horns));     // produces: \\m/ Is there a trick to the logging console for Roll20?
1589834216
The Aaron
Roll20 Production Team
API Scripter
The log function defaults to JSON.stringify() on single variables passed to it.  try: const horns = "\\m/"; log(`${horns}`);
Hmm... that produces: "\\m/" ...still with the double slashes in. If it helps, you can see what I'm ultimately trying to produce with this:         const logsig = '\n' +             '    _________________________________________     ' + '\n' +             '    \_______________________________________/     ' + '\n' +             '      \___________________________________/       ' + '\n' +             '           ___| |_______________| |___            ' + '\n' +             '          |___   _______________   ___|           ' + '\n' +             '              | |               | |               ' + '\n' +             '              | |               | |               ' + '\n' +             '              | |               | |               ' + '\n' +             '              | |               | |               ' + '\n' +             '              | |               | |               ' + '\n' +             '              | |               | |               ' + '\n' +             '_____________VVVVV_____________VVVVV______________' + '\n'; So that would be sitting out in the console on spinning up the sandbox. Only I can't get the slashes right.
1589839754
The Aaron
Roll20 Production Team
API Scripter
You'd need to log those individually, the \n would just get output  and it would all be on one line. You might need to resort to some Unicode: const horns = "\u29f9m\u29f8"; log(horns);
Unicode did the trick, The Aaron, thank you! I modified the characters you selected just for the overall effect. Two things... first, the "new line" characters do render correctly, for whatever that's worth. Second, a question... I used the unicode values to assign to the strings, but I found that once rendered, I could cut & paste them into the dev window. Is there a particular problem with that approach? Some encoding problem I am not foreseeing? Here's what I'm using now:         const logsig = '\n' +             '   ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗     ' + '\n' +             '    ∖_______________________________________∕     ' + '\n' +             '      ∖___________________________________∕       ' + '\n' +             '           ___┃ ┃_______________┃ ┃___            ' + '\n' +             '          ┃___   _______________   ___┃           ' + '\n' +             '              ┃ ┃               ┃ ┃               ' + '\n' +             '              ┃ ┃               ┃ ┃               ' + '\n' +             '              ┃ ┃               ┃ ┃               ' + '\n' +             '              ┃ ┃               ┃ ┃               ' + '\n' +             '              ┃ ┃               ┃ ┃               ' + '\n' +             '______________┃ ┃_______________┃ ┃_______________' + '\n' +             '             ⎞⎞⎛⎛            ⎞⎞⎛⎛      ' + '\n';         log(`${logsig}`);
1589907104
The Aaron
Roll20 Production Team
API Scripter
Nice about the carriage returns working.  Probably it works because of the Template Literal you're passing to log, that's good to know! You can copy/paste the unicode characters freely, the only concern would be if you loaded them into an external editor that didn't support unicode, you would get some strangeness.