I’ve added a new feature to all versions of RiveScript (Perl/Python/Java/JS) that lets you override the parser’s behavior when you use the ^continue command in your code (to break one long line of code into multiple).
The old behavior was to just join the two lines together without adding any spaces or line breaks in between. This is still the default, but now you can change it to add a space or line break in between.
Consider this example, where you want the bot to tell a poem and you want it formatted nicely with line breaks in between:
+ tell me a poem
- Little Miss Muffit sat on her tuffet\n
^ in a nonchalant sort of way.\n
^ With her forcefield around her,\n
^ the Spider, the bounder,\n
^ Is not in the picture today.
If not for those literal “\n” characters in there, the bot’s resulting reply would’ve been even uglier:
Human> Tell me a poem
Bot> Little Miss Muffit sat on her tuffetin a nonchalant sort of way.With her forcefield around her,the Spider, the bounder,Is not in the picture today.
Anyway, now you can do this:
// after this line, all ^ lines add an automatic line break
! local concat = newline
+ tell me a poem
- Little Miss Muffit sat on her tuffet
^ in a nonchalant sort of way.
^ With her forcefield around her,
^ the Spider, the bounder,
^ Is not in the picture today.
Now the poem will work how you want and you don’t need to muddy the code up with \n characters everywhere.
The `! local concat` option takes effect for the current file only and it will affect the parsing of all subsequent lines after its declaration.
It means if you only have one trigger where you want newlines for each ^continue, you can do `! local concat = newline` above, and go back to the default with `! local concat = none` afterward.
The option only affects the current file, so it’s backward compatible and you can use third party *.rive files others have made without accidentally breaking them. If you prefer always having line breaks (or spaces) in all your files, just copy the `! local` command at the top of each one.
The valid options for this command are:
[ul][li]none = the default, inserts no extra characters[/li]
[li]space = inserts a space character[/li]
[li]newline = inserts a line break (\n) character[/li][/ul]