rivescript-js
rivescript-js copied to clipboard
Dynamic Arguments to <call> Tag
One of the comments in an earlier issue (How do I chain replies) mentioned that setting a variable by calling a macro, like below, is a harder problem to solve.
<set myResult=<call>...</call>>
Is there any update on this? We need a way to pass a dynamic date parameter to the <call>
tag.
You can set user variables from inside the macro if that works.
rs.setUservar(rs.currentUser(), "myResult", "x");
@kirsle, I have tried the following but the args in the sub are empty.
Is this because "get" is evaluated before calls are processed?
! version = 2.0
+ test
- <call>date</call> <call>sub <get date></call>
> object date javascript
rs.setUservar(rs.currentUser(), "date", new Date().toString());
< object
> object sub javascript
console.log(args);
return "Args: " + args.join(',');
< object
Yeah the <call>
tag is always the very last one processed. You could use rs.getUservar()
inside the macro to get the variable too.