PDA

View Full Version : Using the Voice action with variables?



quixote
October 19th, 2005, 02:23 PM
Is it possible, and if so, what is the syntax? If not, can you please consider implementing it? I see nothing in the manual.

I'm using this script to create the variable "TimeofDay":


local time = win.GetLocalTime ()
hour = tonumber (time.Hour)

function GetTimeofDay ()
if hour < 12 then
return "Morning"
end
if hour < 17 then
return "Afternoon"
end
return "Evening"
end

TimeofDay = GetTimeofDay &#40;&#41;

and I would like to be able to use the voice action to say "Good {TimeofDay}, blah blah blah"

Thanks.

birty
October 19th, 2005, 02:47 PM
Voice&#58;Speak &#40;string.format&#40;"Good %s blah blah blah",TimeofDay&#41;,sync&#41;

should work

quixote
October 19th, 2005, 05:39 PM
Ah, ok. I thought maybe I could just use the action and insert a variable in there somewhere with brackets or some such thing.
Thanks Birty.

birty
October 19th, 2005, 11:58 PM
i seem to remember square brackets represent lua variables?

Promixis
October 20th, 2005, 01:55 AM
i seem to remember square brackets represent lua variables?

correct

quixote
October 20th, 2005, 04:08 AM
Thanks. Damn - I knew they were brackets, but for some reason I was convinced that they were these {} for some reason. :roll:

That's good to know, and I found that your line of script works great too.

Mastiff
October 20th, 2005, 06:03 AM
Maybe you got the {} from NetRemote?

quixote
October 20th, 2005, 06:15 AM
I don't use Netremote, but perhaps I read it somewhere in someone else's post pertaining to NR.