When looking for a reply to a matched trigger...
1) If any redirection exists (@), it will redirect to that trigger immediately. Also, in case you ask this later, if there is more than one @ for some reason, only the last one is used (the spec only allows for a single @, and I coded the perl rivescript interpreter to only keep room for one, so each @ it finds is copied to the same variable overwriting the previous one).
2) If any conditions exist, it will test all the conditions in the order they appeared in the source code.
3) If no reply was found yet (no redirection, or all the conditions were false), then it looks at the replies. If there's more than one it picks them randomly.
So..
Code:+ question 1
* condition 1
* condition 2
- unconditional aswer
If you say "question 1", it will try condiiton 1 first, then condition 2, and if neither one is true then it gives the unconditional answer.
+ question 2
* condition 1
* condition 2
- unconditional aswer 1
- unconditional answer 2
here it'll try condition 1, then condition 2, and if neither is true it will randomly pick between unconditional answer 1 and 2.
If you want random redirections, you can use the inline redirection format.
+ question
- {@answer one}
- {@answer two}
As for the extension commands... your questions are uncovering some interesting errors in my perl module.
The ^ command is supposed to be able to extend all other commands. When it does so, it should not add any spacing of its own; if the writer intends for there to be a space between the joined parts they should insert the \s tag. This is how it *should* behave:
Code:- answer
^answer second part
^answer third part
is equivalent to:
- answeranswer second partanswer third part
and:
* condition
^ condition part 2
^ condition part 3
is equivalent to:
* conditioncondition part 2condition part 3
and:
@ redirect
^ redirect part 2, etc...
is equivalent to:
@ redirectredirect part 2, etc...
Although, in testing this with the Perl RiveScript interpreter, I found some bugs that I need to fix. Here's my test code:
Code:+ test one
- answer
^ answer second part
^ answer third part
/*
+ test two
* <id> ==
^ localuser =>
^ conditions can span multiple lines too
- normal reply
*/
+ test three
* <id> == localuser => conditions
^ can span multiple lines too
- normal reply
+ test four
@ test
^ one
+ test five
@ test
^ \sone
The output:
Code:You> test one
Bot> answeranswer second partanswer third part
You> test two
Bot> ERR: No Reply Matched
You> test three
Bot> conditionscan span multiple lines too
You> test four
Bot> ERR: No Reply Matched
You> test five
Bot> answeranswer second partanswer third part
You> ^C
So, there's a few bugs here:
* Test one behaved the way I expected it to.
* Test two gave me syntax errors, so I had to comment it out of the file. It said "Syntax error in ./extend.rs line 6: Invalid format for !Condition: should be like `* value symbol value => response` (near: * <id> ==)"
* Test three worked the way I expected it to. After the syntax error from test two I rewrote it so that the majority of the condition logic is on the same line, and the only part extended is the response part for the condition.
* Test four worked the way I expected it to. Since the join caused the line to be effectively "@ testone" with no space, it didn't match any trigger.
* Test five also worked the way I expected it to. I put a \s in there so that the redirection became "@ test one" -- however, there was a small bug. If I put the \s on the same line as the @ symbol, it gave me a syntax error, saying that "\s" isn't a legal character for a trigger or redirection.
So, generally yes, the ^ command can extend any other command. I just need to fix my Perl module so that it doesn't whine about syntax errors before it actually joins the lines together. My commented-out condition test should've worked just fine, for example.
The spec can still be changed though, so certain things could still be added to it, such as allowing multiple @ commands for a single reply and have them be chosen randomly...