Favorite color variable

Tips and questions about scripting your Verbot®.

Moderator: Staff

Favorite color variable

Postby chatterbox-challenge » Tue Aug 02, 2011 6:09 pm

I started to store someone's favorite color based on the saving someone's name example.

Rule Name: my favorite color

Input Text: my favorite color is [fav_color]

Output Text: Cool, I think [fav_color] is a pretty color.
Output Text: Nice, I like the color [fav_color] a lot.

Then

Rule Name: what is my favorite color

Input Text: what is my (favorite) (color)
Input Text: my (favorite) (color) is what

Output Text: You told me your favorite color was [fav_color].


All the above works.


When I added this as a possible input such as if someone typed this

Red is my favorite color

[fav_color] is my favorite color


Then if someone ask: What is my favorite color?

Then I'm getting:


You told me your favorite color was what.


I see what it is doing. Not sure how to correct it though.
chatterbox-challenge
ScribeBot
ScribeBot
 
Posts: 73
Joined: Fri Feb 11, 2011 1:24 pm

Postby JonC » Wed Aug 03, 2011 7:27 am

here's one possible solution:
At start-up define [fav_color] as being <space>.
<mem.set fav_color > nb there are two spaces in there!

Then make your what is my favourite color input conditional on
[fav_color] != " "
and [fav_color] is my favourite color conditional on
[fav_color] == " ".
This way only the "right" rule will trigger.
Last edited by JonC on Wed Aug 03, 2011 7:12 pm, edited 1 time in total.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Postby chatterbox-challenge » Wed Aug 03, 2011 5:02 pm

At start-up define [fav_color] as being <spave>.
<mem.set fav_color > nb there are two spaces in there!


I'm not sure what you mean here. I do have a _startup rule. Do I place the above somewhere in there or do I have the wrong place?

And what am I placing there exactly. I don't know what "as being <spave>" means nor the initials "nb"?




Rule Name: _startup
Input Text: _startup
Output Text: Hello [name:Friend]
Output Text: Hi [name:Friend], I'm so glad you're back.
Output Text: Hey [name:Friend], good to see you again.
chatterbox-challenge
ScribeBot
ScribeBot
 
Posts: 73
Joined: Fri Feb 11, 2011 1:24 pm

Postby JonC » Wed Aug 03, 2011 7:18 pm

That should be "space" :oops: (I've now edited it!)

nb = note carefully (in English).

You are using your startup rule in a different way to me.
I use the startup rule itself to set a whole number of vars-variables to inital values (either real values or "nulls" or blanks).
I then <send ...> to the first (child) rule to action.

So what I would do is rename your current _startup as startup1, create a new _Startup rule for variable setting then move startup1 (the old startup) to be the child of the (new) )_Startup.
My last line in _Startup would then be <send startup1>
(That's only one solution, mind you.)
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Postby leseur sylvain » Thu Aug 04, 2011 9:20 am

I just sent to you a little file.
Sy.
leseur sylvain
OmnipotentBot
OmnipotentBot
 
Posts: 1680
Joined: Mon Nov 08, 2004 4:53 pm
Location: Suburb of Paris France

Postby chatterbox-challenge » Thu Aug 04, 2011 7:07 pm

Sylvain,

I don't understand the file sent other than to say it doesn't seem to address the input of Red is my favorite color.

Jon,

I now have

_startup with

_startup 1 as child


What goes in startup and where? You never said. Does
<mem.set fav_color > go in input or conditional?

Does <send startup1> go in input, output, conditonal ?


At start-up define [fav_color] as being <space>.


Still have no idea what that means or how to write it.


I seem to get syntax error on the below. How exactly do you write that.


[fav_color] != " "
[fav_color] == " ".
chatterbox-challenge
ScribeBot
ScribeBot
 
Posts: 73
Joined: Fri Feb 11, 2011 1:24 pm

Postby leseur sylvain » Thu Aug 04, 2011 7:23 pm

Try to use
<?csharp vars["fav_color"] = "red";?>
in your output _startup rule.
Sylvain.
leseur sylvain
OmnipotentBot
OmnipotentBot
 
Posts: 1680
Joined: Mon Nov 08, 2004 4:53 pm
Location: Suburb of Paris France

Postby JonC » Fri Aug 05, 2011 2:14 pm

If you are (now) using _Startup as a rule to "initialise" your Verbot,
then any <mem.set ...>s go in the rule output (after all you want the Verbot to do this stuff).
The _Startup rule would normally be unconditional and execute a series of commands either c# or Verbot (eg mem.sets or Sylvain's c# snippet) to set a number of initial vars-variable conditions.
To be utterly explicit about this:

Rule Name: _Startup
Input: _Startup
Output: <?csharp vars["fav_color"] = "";?>

Input and output remain unconditional. I've chosen to set fav-color to a null value initially, rather than red.

Don't forget you can use CNTRL-RTN to get a new line on your output if you want more initialisation.
Last edited by JonC on Sat Aug 06, 2011 7:19 am, edited 1 time in total.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Postby chatterbox-challenge » Fri Aug 05, 2011 5:36 pm

[
fav_color] != " "
and [fav_color] is my favourite color conditional on
[fav_color] == " ".


These conditional lines mentioned in previous post only gives me syntax error.
chatterbox-challenge
ScribeBot
ScribeBot
 
Posts: 73
Joined: Fri Feb 11, 2011 1:24 pm

Postby JonC » Sat Aug 06, 2011 7:15 am

My bad, here's the correct syntax:

vars["fav_color"] != " "
vars["fav_color"] == " "
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Postby chatterbox-challenge » Mon Aug 08, 2011 4:09 pm

I still can't seem to get this right. I am getting a warning of something like "the database contains code that maybe dangerous to your computer." Among other issues.

Can you take a look and see what I'm doing wrong?

To recap I want to be able to save what someones favorite color is by using these 2 basic inputs

red is my favorite color
my favorite color is red.

Then if someone ask what their favorite color is before actually stating so I would like to respond with:

Sorry, I don't recall you telling me what your favorite color was.

If present then being able to say: You told me your favorite color is [fav_color]





http://www.daniellechuchran.com/colors.vkb
chatterbox-challenge
ScribeBot
ScribeBot
 
Posts: 73
Joined: Fri Feb 11, 2011 1:24 pm

Postby leseur sylvain » Mon Aug 08, 2011 4:39 pm

Arghhhhhh....
The file i sent you, do this....
Can you send me your complete files and a typic conversation;

Friendly.
Sylvain.
leseur sylvain
OmnipotentBot
OmnipotentBot
 
Posts: 1680
Joined: Mon Nov 08, 2004 4:53 pm
Location: Suburb of Paris France

Postby chatterbox-challenge » Mon Aug 08, 2011 5:57 pm

I loaded the file you sent. I type in "What is my favorite color" I get this.


Okay, I'll remember that. what? is tour favorite colour...

This is the reason I started the post to begin with.
chatterbox-challenge
ScribeBot
ScribeBot
 
Posts: 73
Joined: Fri Feb 11, 2011 1:24 pm

Postby leseur sylvain » Mon Aug 08, 2011 6:30 pm

You forgot the " ? "

What is my favorite color ?


//
If you want " ? " has no effect: In Verbot Scripting Editor

Tools/Replacement profile/
Create a Replacement Profile file.
Cllic on Little icon
Add default input Replacement

(Like that "?" = to nothing/has no effect.)

Then add your file in:
Verbot Scripting Editor --> Resource Files Détails

Sylvain.
leseur sylvain
OmnipotentBot
OmnipotentBot
 
Posts: 1680
Joined: Mon Nov 08, 2004 4:53 pm
Location: Suburb of Paris France

Postby JonC » Tue Aug 09, 2011 4:27 pm

Any time a Verbot KB contains c#, it always says "the database contains code that maybe dangerous to your computer."
This is a 'generic' warning in that the code (if improperly written) :D could harm your computer.
Ignore and "okay" it.

As to the "other issues", it's a bit hard to resolve them if you don't say what they are!

Then if someone ask what their favorite color is before actually stating so I would like to respond with:

Sorry, I don't recall you telling me what your favorite color was.


We've already set vars["fav-color"] to an empty string in the startup rule (and here is why I prefer that to Sylvain's method).
What you can do is check that vars["fav_color"] is equal to "" in the rule output condition
vars["fav_color"] != "" ) and then use the output:
Sorry, I don't recall you telling me what your favorite color was.

This output, since it is conditional, will trigger as being "more correct" than an unconditionally correct rule - your other responses.

I loaded the file you sent. I type in "What is my favorite color" I get this.

Okay, I'll remember that. what? is tour favorite colour...

This is the reason I started the post to begin with.


I suspect that you've still got the rule with the input:
[fav_color] is my favorite color as well as a rule called what is my favorite color.
Thus when you query the kb by asking it "what is my favorite color?"
then you are "firing" the [fav_color] is my favorite color rule and thus setting [fav_color] to "what".
To cure this use vars["fav_color"] == "" in the input condition of this rule.
Then this rule will only fire if, and only if, there is no value for [fav_color] set.
To make really certain you get the result you want put the condition vars["fav_color"] != "" in the "what is my favorite color" rule input condition as well.
hence one rule is only true when no favorite color is set and the other is only true when the favorite color isn't set.

You might also care to look at the wiki (or download the Verbot4 editor help file) and see if alternative text in a rule would also provide you with a solution.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron