Author Topic: Wait a change value before continue script  (Read 3946 times)

Sloboda

  • Jr. Member
  • **
  • Posts: 74
  • VoiceCommander Creator
    • A.M.I.S. X Plane
Wait a change value before continue script
« on: March 11, 2017, 09:21:25 AM »
Hello,
i would like to do:

turn button1 on, and:

when value1 change 1 to 0, turn button2 on.......

I have try to code:

execute turn button1 on

start loop while value1 is 1
get value1
pause 0.5s
end loop

execute turn button 2..........

But all buttons turn on at same time.

Have you an idea please ?
Thank you very much

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4778
  • RTFM
Re: Wait a change value before continue script
« Reply #1 on: March 11, 2017, 10:01:45 AM »
Can you right-click an item in the action list of your command, click the "Copy All as Text" entry, and paste it to the forums?

Sloboda

  • Jr. Member
  • **
  • Posts: 74
  • VoiceCommander Creator
    • A.M.I.S. X Plane
Re: Wait a change value before continue script
« Reply #2 on: March 11, 2017, 10:05:27 AM »
Hello Pfeil,

Execute command, 'set adir display to s t s' (and wait until it completes)
Pause 0.5 seconds
Execute command, 'set adir system to one' (and wait until it completes)
Pause 0.5 seconds
Execute command, 'adir one on nav' (and wait until it completes)
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Pause 0.5 seconds
End Loop
Execute command, 'adir two on nav' (and wait until it completes)
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Pause 0.5 seconds
End Loop
Execute command, 'adir three on nav' (and wait until it completes)
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Pause 0.5 seconds
End Loop
Set decimal [xplane!sim/custom/xap/adirs/knob_ent] value to 1
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return


So, i turn on ADIR one on Nav and i must wait adirs/on_bat equals 0 before turn Adir2 On Nav.....etc...

Sloboda

  • Jr. Member
  • **
  • Posts: 74
  • VoiceCommander Creator
    • A.M.I.S. X Plane
Re: Wait a change value before continue script
« Reply #3 on: March 11, 2017, 10:08:14 AM »
Some details are not present in this copy i'm sorry.

For example, i complete:

Execute command, 'set adir display to s t s' (and wait until it completes)
Pause 0.5 seconds
Execute command, 'set adir system to one' (and wait until it completes)
Pause 0.5 seconds
Execute command, 'adir one on nav' (and wait until it completes)
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return     (GetValue xplane!sim/custom/xap/adirs/on_bat)
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
    Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return   (GetValue xplane!sim/custom/xap/adirs/on_bat)
    Pause 0.5 seconds
End Loop
Execute command, 'adir two on nav' (and wait until it completes)
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
    Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
    Pause 0.5 seconds
End Loop
Execute command, 'adir three on nav' (and wait until it completes)
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
    Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
    Pause 0.5 seconds
End Loop
Set decimal [xplane!sim/custom/xap/adirs/knob_ent] value to 1
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return

Sloboda

  • Jr. Member
  • **
  • Posts: 74
  • VoiceCommander Creator
    • A.M.I.S. X Plane
Re: Wait a change value before continue script
« Reply #4 on: March 11, 2017, 10:10:33 AM »
The command is: Set ADIRS to align

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4778
  • RTFM
Re: Wait a change value before continue script
« Reply #5 on: March 11, 2017, 10:19:32 AM »
What you're doing looks correct, but have you checked the actual value of "xplane!sim/custom/xap/adirs/on_bat"?

If the value is "Not Set", the loop will also end, as "Not Set" does not equal "1".

Throw a "Write a Value to the Event Log" action in there:
Code: [Select]
Write '[Purple] {DEC:xplane!sim/custom/xap/adirs/on_bat}' to log


That aside, I'd swap around the order within your loop:
Code: [Select]
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
    Pause 0.5 seconds
    Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
End Loop
The way you have it set up right now means the data is 500ms old when the loop checks the value, so if the value changes between getting the data and the loop coming around, you may need to wait up to 1000ms to actually register the change.

Sloboda

  • Jr. Member
  • **
  • Posts: 74
  • VoiceCommander Creator
    • A.M.I.S. X Plane
Re: Wait a change value before continue script
« Reply #6 on: March 11, 2017, 10:32:45 AM »
Thank you Pfeil,

i have understand, that's work now. I have add pauses between "turn on" and the GetValue, because value had not enough time to change, so, the value was always 0.

Now the code is like is and that's work:

Execute command, 'set adir display to s t s' (and wait until it completes)
Pause 0.5 seconds
Execute command, 'set adir system to one' (and wait until it completes)
Pause 0.5 seconds
Execute command, 'adir one on nav' (and wait until it completes)
Pause 0.5 seconds
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
    Pause 0.5 seconds
    Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
    Write '[Purple] xplane!sim/custom/xap/adirs/on_bat' to log
End Loop
Execute command, 'adir two on nav' (and wait until it completes)
Pause 0.5 seconds
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
    Pause 0.5 seconds
    Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
End Loop
Execute command, 'adir three on nav' (and wait until it completes)
Pause 0.5 seconds
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
Start Loop While : [xplane!sim/custom/xap/adirs/on_bat] Equals 1
    Pause 0.5 seconds
    Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return
End Loop
Set decimal [xplane!sim/custom/xap/adirs/knob_ent] value to 1
Execute external plugin, 'SPAD.neXt VoiceAttack Plugin - v0.9.5+' and wait for return


thank you very much for your help.