Author Topic: Can't figure out how to complete this  (Read 4260 times)

KuruptU4Fun

  • Guest
Can't figure out how to complete this
« on: April 16, 2017, 01:50:27 PM »
I'm working on a HOTAS bind for my X-55 and I need some guidance on how to do the following:

In the in game HOTAS layout I've got the button set to change from landing mode to flight mode as a double tap. But what I want VA to do is recognize a that a single tap should move the ship up a few feet in takeoff and hover before going into a different flight mode.


I think I can approach this as a recorded bind that uses a true false Boolean compares. True being that one tap it jumps off of the landing pad a few feet and hovers and false being two taps to jump to the landing mode change I need it to.

This is from a state where I just got into the ship

Begin Boolean Compare : [LandingPadVariable] Equals False
    Set Boolean [LandingPadVariable] to True
    Press Space key and hold for 3 seconds and release
    Play sound, '{VA_SOUNDS}\hcspack-VEGA\Characters\Referencing\Prepare for takeoff.wav'
    Jump to Marker: JumptoFlightMode
Else
    Set Boolean [LandingPadVariable] to False
    Press N key and hold for 0.25 seconds and release
    Pause 0.25 seconds
    Press N key and hold for 0.25 seconds and release
End Condition
Marker: JumptoFlightMode



Press N key and hold for 0.05 seconds and release THIS NOW NEEDS TO BE "Double Tap" it plays the following:

Begin Boolean Compare : [Flight Mode] Does Not Equal True
    Set Boolean [Flight Mode] to True
    Execute command, 'SF Flight Mode' (by name) (and wait until it completes)
Else
    Set Boolean [Flight Mode] to False
    Execute command, 'SF Landing Mode' (by name) (and wait until it completes)
End Condition

Does this look right or would the two Boolean Compares break the idea I'm going for? Thanks for the help in advance!
« Last Edit: April 16, 2017, 02:09:24 PM by Matthew Evans »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Can't figure out how to complete this
« Reply #1 on: April 16, 2017, 03:31:49 PM »
Begin Boolean Compare : [LandingPadVariable] Equals False
    Set Boolean [LandingPadVariable] to True
    Press Space key and hold for 3 seconds and release
    Play sound, '{VA_SOUNDS}\hcspack-VEGA\Characters\Referencing\Prepare for takeoff.wav'
    Jump to Marker: JumptoFlightMode
Else
    Set Boolean [LandingPadVariable] to False
    Press N key and hold for 0.25 seconds and release
    Pause 0.25 seconds
    Press N key and hold for 0.25 seconds and release
End Condition
Marker: JumptoFlightMode
Is this the full action list? If so, that jump appears to be redundant. If the first branch on a condition executes, the second branch will not, so execution would automatically continue where you've placed the jump marker after "Prepare for takeoff.wav" starts playing.

Press N key and hold for 0.05 seconds and release THIS NOW NEEDS TO BE "Double Tap" it plays the following:

Begin Boolean Compare : [Flight Mode] Does Not Equal True
    Set Boolean [Flight Mode] to True
    Execute command, 'SF Flight Mode' (by name) (and wait until it completes)
Else
    Set Boolean [Flight Mode] to False
    Execute command, 'SF Landing Mode' (by name) (and wait until it completes)
End Condition

Does this look right or would the two Boolean Compares break the idea I'm going for?
Can you clarify what you expect should happen?

With the snippets you have here, pressing the first time would execute the command "SF Flight Mode", pressing the second time executes the command "SF Landing Mode", and pressing the third time again executes the command "SF Flight Mode", and so on, alternating between both commands with each button press.

If you want to detect double presses within VoiceAttack itself, make a command triggered by your button press containing something like the following:
Code: [Select]
Begin Text Compare : [{EXP:({DATETICKS} - {DEC:PressedLast}) <= 10000000}] Equals '1'
    Begin Small Integer Compare : [Pressed] Is Less Than 1
        Set small int (condition) [Pressed] value as incremented by 1
    Else If Small Integer Compare : [Pressed] Equals 1
        Write '[Purple] Double press detected' to log
    End Condition
Else
    Set small int (condition) [Pressed] value to 1
End Condition
Set decimal [PressedLast] value to the converted value of {DATETICKS}
It's a little more complex than it needs to be, as it was originally a triple-tap instead, but you can swap out the small int for a bool if you want.

10000000 ticks should equate to 1000ms, or one second; You can lower this value if you want to filter out accidental double presses.

KuruptU4Fun

  • Guest
Re: Can't figure out how to complete this
« Reply #2 on: April 16, 2017, 07:26:02 PM »
The double tap is to change flight modes in SC, Flight mode being wheels up and full speed, landing mode being reduced speed and landing gear down with the default being in landing mode.

There is no auto "takeoff" built into the game which is what I'm trying to build, with the double tap to change the modes into a single HOTAS button.

(Begin Text Compare : [{EXP:({DATETICKS} - {DEC:PressedLast}) <= 10000000}] Equals '1')

Where do I build that in menu?
« Last Edit: April 16, 2017, 07:50:32 PM by Matthew Evans »

KuruptU4Fun

  • Guest
Re: Can't figure out how to complete this
« Reply #3 on: April 17, 2017, 06:10:26 AM »
Pheil,

Since the change to flight mode is a keystroke that's done in game I thought this might work:

I use a VA button stroke to take off or wait 3 seconds which gives me time to double click the HOTAS button in the Bool.
 
Begin Boolean Compare : [TakeofforFlightModevariable] Equals True
    Press variable key(s) [Spacebar] and hold for 3 seconds and release
Else
    Pause 3 seconds
End Condition
Begin Boolean Compare : [Flight Mode] Does Not Equal True
    Set Boolean [Flight Mode] to True
    Execute command, 'SF Flight Mode' (by name) (and wait until it completes)
Else
    Set Boolean [Flight Mode] to False
    Execute command, 'SF Landing Mode' (by name) (and wait until it completes)
End Condition
« Last Edit: April 17, 2017, 06:18:06 AM by Matthew Evans »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Can't figure out how to complete this
« Reply #4 on: April 17, 2017, 09:05:43 AM »
If all you need to do is detect the double button press:
Code: [Select]
Begin Text Compare : [{EXP:({DATETICKS} - {DEC:PressedLast}) <= 10000000}] Equals '1'
    Write '[Purple] Double press detected' to log
Else
    Write '[Purple] Single press detected' to log
End Condition
Set decimal [PressedLast] value to the converted value of {DATETICKS}
Paste
Code: [Select]
{EXP:({DATETICKS} - {DEC:PressedLast}) <= 10000000}Into the "Variable Name / Token" field of the first Text Compare.

KuruptU4Fun

  • Guest
Re: Can't figure out how to complete this
« Reply #5 on: April 18, 2017, 05:56:37 AM »
Pheil thanks for the help,


Are there any good "intro" projects into Text (and Text-To-Speech) Tokens you can suggest?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Can't figure out how to complete this
« Reply #6 on: April 18, 2017, 08:31:00 AM »
Are there any good "intro" projects into Text (and Text-To-Speech) Tokens you can suggest?
I'd recommend looking into some basic computer programming tutorials. If you can grasp the logic behind them, using tokens correctly becomes a case of looking up the syntax and applying it.

There's no "one simple trick" to it, you learn by doing. I personally find it works best to have a real-world application rather than a hypothetical exercise, so you both understand and have an interest in the end goal.