Author Topic: Loop question  (Read 2466 times)

Nico1854

  • Guest
Loop question
« on: December 04, 2016, 03:08:10 AM »
I have a txt file that I read with a plugin.

The tx file is updated every second.

I'm importing the values from that text file into a visual basic plugin then passing them to VA.

Would it be better to set the loop in the pluggin or in VA ?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Loop question
« Reply #1 on: December 04, 2016, 02:26:29 PM »
Better is debatable, but you can make a plugin execute a command, so you could have the plugin run in the background monitoring the variable, and trigger a command when it's relevant.

The advantage of a command in VoiceAttack would be ease of use. You can modify the actions without having to recompile the plugin, and frankly it's simpler to put together.


If you opt for a loop inside the plugin, I would strongly suggest you make it possible to shut the loop down.

You could use the plugin context to pass either a "Start" or "Stop" directive, which would either start the loop(if it's not already running), or stop it, respectively.

Under "VA_Invoke1" you'd have something like the following:
Code: [Select]
If vaProxy.Context = "Start" Then
    If LoopRunning = False Then
        LoopRunning = True
        'Insert your While loop that runs as long as "LoopRunning = True"
    Else
        vaProxy.WriteToLog("Start called when loop is already running", "red")
    End If
ElseIf vaProxy.Context = "Stop" Then
    LoopRunning = False
End If
Aside from filling in the loop, you'll also have to declare the boolean "LoopRunning" somewhere where it won't be cleared when "VA_Invoke1" is called.