Author Topic: Determining the output of functions that aren't documented in the PDF  (Read 4347 times)

Dazlarus

  • Newbie
  • *
  • Posts: 2
I have been trying to write my first inline function. The basic idea is that I want my script to check the activity log every few minutes and see if VA has detected that I have said anything since the last time it checked. I have most of it there and should work, my main issue is that I don't know the output of VA.Command.LastSpoken() or how to check.

There isn't any information about this function of VA.Command in the help PDF, or at least I couldn't find it. Obviously, if there is a better way of reading the activity log, please share :) but I am mainly interested in how to check the output of functions like this. My normal method of finding undocumented information in other APIs I have worked with is to write some debug code that outputs the result of the function to the console. Unfortunately my test code:
Code: [Select]
Console.WriteLine(VA.Command.LastSpoken()); has no output when I hit the test run button in the VA inline function editor.  >:(

I stream on Twitch and have turned VoiceAttack into a stream assistant that I call EnsignKarl. My audience can interact with "him" and I have many quirky dialogue trees with him. The goal of this inline function is to have him kill the dead air by asking me questions, throwing wild lines, or whatever else I decide to add in the future. I use VoiceAttack with an open mic so I figure that I can have the function "watch" the activity log. If I have been quiet for too long then Karl can kick start me... or at least that's the plan.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
...do you have a console window open (and associated with VoiceAttack)? The Console.WriteLine() method is intended for console applications, E.G. running in a cmd window.

As the documentation notes, the VA.WriteToLog() method outputs to the log on the main window.


What about the "LastSpoken()" method is not documented?
Quote from: VoiceAttackHelp.pdf
LastSpoken() – returns a string which indicates the last-spoken command phrase. Useful from within sub-commands where you need to know what was said to invoke the root command, or if you need to know what was spoken prior to the current command (if the current command was not spoken (executed by keyboard, mouse, joystick, external, etc.).

This is not directly related to the "activity log". Also note that it is the equivalent of the "{LASTSPOKENCMD}" token, I.E. it returns the last recognized spoken command, not whatever the speech recognition engine last recognized (which is what the "{LASTSPOKEN}" token would return)

E.G. if your command's "When I say" field contains "[an;] example command;an alternate phrase", and you speak "example command", the output of the LastSpoken() method would be "example command" (as mentioned, it is not directly related to the log on the main window, so there is no timestamp; you could look at the LastUserExec() method for something along those lines, though that applies to all commands, not just spoken ones)

There is no native (to VoiceAttack) method for retrieving the contents of the log programmatically.
« Last Edit: June 20, 2021, 09:14:23 PM by Pfeil »

Dazlarus

  • Newbie
  • *
  • Posts: 2
Thank you for the explanation. I am very new to VoiceAttack. In the past, I have worked mostly in JavaScript in a browser or C# in game engines (Unity, UE4) or in Visual Studio, and in these environments, the debug log has also been the place where console stuff is written (or at least near the debug log.) Knowing that the expected workflow in VA is to use the activity log as your debug log it makes sense why Console.WriteLine didn't behave as I expected.

As for the documentation thing... I have no earthly idea how I couldn't find that the other day. I feel like a bit of an idiot haha.

Bummer that there isn't a way to retrieve activity log information. Looks like I will need to go outside of VA to monitor my audio inputs for words and use keybinds to get the functionality I was looking for. Thank you @Pfiel for all your help!