
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.
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;
1) Set the date of birth in EZ-Script
2) Subtract the date of birth from the current date
3) Convert days to days, months and years
4) Speak the result
Alternately, use PandoraBot, you can set a DOB in there and it does the calcs for you
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.
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;
Code:
For year and month
Code:
With the latter you could use further ifs to force ages below 3 years to months only (as we tend to do with children).
Code:
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.
Thanks again for your help Rich.
***EDIT*** variable or constant I should say...