-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
variables returned from native JS methods #234
Comments
so this line but these do not match: |
FWIW the parseAge native JS funcs are wrapped as a Promise like:
I could see if there was an issue with values not being available right away from the native JS method returns, which i saw here: However, I can run this again or call dbg again, and still not get any matching on these simple string conditional compares. I deliberately avoid I can only guess that the return from the JS native methods are actually some type of complex types that fail on RiveScript conditional compares. Are there any other examples? I tried matching with This is driving me nuts 😭 😭 😭 ! |
Digging through the issues I found this:
I am using v1.17.2
So the workaround for that if we want the value immediately is to set the userVars from within the native JS method? However, that still doesn't explain the above, as the value is showing as |
OK yeah, so this is what I see being set in the uservars natively inside the object:
and that just displays / parses as |
Since reading your first comment I was staring at this bit of code:
And I'm pretty sure that syntax doesn't work (well) in any version of RiveScript. The What I think is going on is that the As for the conditional lines themselves and why they don't work by accident in the same way: if the object macros return promises, they won't work in conditionals. Some work will be needed to use Async/Await like #220 to make async macros work in conditionals. |
What I always suggest doing instead when somebody wants to |
I think I found another problem that setting uservars inside the macro, it seems to require another "tick" of the system for those values to be available to RS code outside the macro. ie the values are not set yet when I would call a conditional "inline". |
Related to this issue, rivescript {@} redirections do not call the javascript macros, so there is no way to modify a variable using js without some user action or that extra "tick"
In the above example, the js macro won't get called unless the user types "call" or "get" |
That sounds like a bug that needs fixing. I wonder if it's calling the wrong reply function under the hood and breaking stuff wrt. object macros and promises. |
aichaos#233 aichaos#234 grammar edits
I have an RS method that returns a string
and I set that string in a variable in Rivescript
But a conditional doesn't match,
even though I also print out the value of the variable to check.
The text was updated successfully, but these errors were encountered: