Asked
— Edited
Resolved by Rich!
Hi guys.
I need a little help with some script. As the title says, I would like to get K-9 to say his age when somebody asks him. For example,
User. "how old are you?"
K-9. "I am 1 year, 2 months, 5 months and 2 days old."
It will obviously need a start date (Date of Birth) then have the script work out the age from that, but so far this weekend I have had a play around with a "Say the Date" script with different variations but have had no luck with it. Does anyone have a script that can be used to do this?
Thanks in advance,
Steve G.
I'm not going to write it for you, but will give you a push in the right direction...
There are the following built in variables in ARC; $date $month $year $day
You also have the following DateTime functions available; MinDate() MaxDate() MonthName() AddDays() AddMonths() AddYears() AddHours() AddMinute() AddSeconds() FmtNum() FmtDate()
You just need to figure out how to;
Alternately, use PandoraBot, you can set a DOB in there and it does the calcs for you
@Rich.... I am sitting here staring at the ceiling trying to figure out how to do this.... LOL. I finally had an idea which was similar to yours, but since my "cpu" is a lot slower than yours you beat me to it... LOL
Thanks for the replies guys. I have been using the $date $month $year and $day codes which the say the date script uses but no matter what I tried I just couldn't get it to work. I think the main problem is setting the date of birth. I would have posted a script to show you guys, but I changed what I had so many times I ended up deleting it in the end.
Thanks for the Pandorabot suggestion Rich, but I was already aware I could do it this way, but I really wanted to do this using Script's so I could learn much more about how EZ Script works and what I could do with it.
Well I gave writing the "Say your age" script again this evening but to no avail. I've obviously still got a way to go with EZ Script but I'm sure I'll get there. Thanks again for the Pandorabot suggestion Rich. I think I will do it this way. As I mentioned I was aware I could do it this way but never tried it, so reluctantly I'm going to go down this route. Would like to have used EZ Script though as I enjoy using it, but I just dont have enough experience to do this just yet. confused
If you want "I am 2 years, 11 months, 14 days, 8 hours, 27 minutes and 37 seconds old" then it's going to be long scripts.
If you wanted something as simple as "I am 7 years old" or "I am 19 months old" then it's a little easier.
For a simple yearly response;
For year and month
With the latter you could use further ifs to force ages below 3 years to months only (as we tend to do with children).
These are just a few quick examples which I hope get you started. I haven't done one for including days, this should be pretty simple to add in if you follow what I did for the years and the months.
I'm glad you provided that example Rich, that much easier than what I was starting to do....which was to take the string of $date and parse it for the values of the month, day and year to do math against a birth date.
That's how I started looking at it earlier today but I've come to learn that there is always a simpler method than how I first think.
That's great. Thanks for the examples Rich. I will give them a try tomorrow. Quite different to what I initially wrote, and a lot shorter. But looking at the examples you supplied some of it is starting to make a bit more sense to me, and I can see parts where I was going wrong, especially setting the birth date, although I'm still not 100% sure I would have fully got it to work.
Thanks again for your help Rich.
Just one more thing I want to ask to get a better understanding of how EZ Script works, like ( ) defines ports ect and " " sets speech or speech commands, what does (in laymans terms ) the "$" sign mean, or rather what does it actually do? I think that's where I was initially having trouble.
$ tells ARC a variable is to follow. In other words this is ARC's way of identifying a variable to be used....
EDIT variable or constant I should say...