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

Multi-line input parsing

1475398994

Edited 1475399041
Jakob
Sheet Author
API Scripter
How can I make my script deal with multi-line input? I.e. suppose my script can already deal with, say !setattr --sel --Strength|15 --Dexterity|17 --Strawberry|Jam as well as Pie How do I make it also accept (TokenMod-style) !setattr {{ --sel --Strength|15 --Dexterity|17 --Strawberry|Jam as well as Pie }} ?
msg.content = msg.content.replace(/<br\/>\n/g, ' ').replace(/({{(.*?)}})/g, " $2 "); This is what TheAaron did for me for PowerCards.
1475444175
Jakob
Sheet Author
API Scripter
Thanks, that helped me get on the right track! I ended up going with .replace(/<br\/>\n/g, '').replace(/({{(.*?)\s*}}$)/g, "$2")
1475464204
The Aaron
Pro
API Scripter
The reason for the " $2 " was to avoid issues where a user didn't indebt their commands on the following lines. I then split on /\s+--/ to break into sub commands.