Author Topic: spoken numbers into integer values  (Read 3402 times)

cargorunner1969

  • Newbie
  • *
  • Posts: 11
spoken numbers into integer values
« on: February 21, 2021, 08:05:49 AM »
i've got a grab scrap command which fires two limpets, opens the cargo scoop but it relies on the command being repeated twice.
clumsy.
i've found out how to set a loop to run x number of times from firstly a set variable and then a keypress but i'm sticking on the voice entry.

i've found some three year old posts but i dont get it...

can anybody help?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: spoken numbers into integer values
« Reply #1 on: February 21, 2021, 03:14:01 PM »
If you're only speaking one number, you can use the "{TXTNUM:}" token to get the numerical characters out of the output of the "{CMD}" token. Otherwise, you'd likely want to use the "{CMDSEGMENT:}" token instead.

You can use either token directly in the "Number of times" field of the "Loop Start - Repeat a Certain Number of Times" action, as that parses tokens (so it converts the text to an actual number internally).

If you want to do math with the value, you'll want to use the "Convert Text/Token" field of the "Set an Integer Value" action (or the "Set a Decimal Value" action of you need non-integer numbers) to convert it into a usable number (technically you could use the "{EXP:}" token, which can also perform an internal conversion, to do math, but that tends to be more complex to learn than using actions).


Press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer.

These topics may also be of use, especially the latter:
Control flow (If, Else, ElseIf, Loop, Jump) basics
Variables and tokens summed up


As an example, if your "When I say" contents are "fire [1..10] limpet mines", the command could look something like
Code: [Select]
Start Loop : Repeat [{TXTNUM:"{CMD}"}] Times
    Press F key and hold for 0,06 seconds and release
End Loop
(substituting F for whichever key actually fires limpet mines, obviously)

cargorunner1969

  • Newbie
  • *
  • Posts: 11
Re: spoken numbers into integer values
« Reply #2 on: February 21, 2021, 08:22:28 PM »
please excuse my lack of coding knowledge.
i entered the code (at least i think i did) as indicated

3:17:36.826 Unable to resolve for loop context: [txt:"{cmd}"].  Exiting command.

ah... i didnt finish the txt command properly.
mybad

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: spoken numbers into integer values
« Reply #3 on: February 21, 2021, 08:24:49 PM »
Tokens are case-sensitive, and with the singular exception of "{time}", all of them are fully upper-case.

cargorunner1969

  • Newbie
  • *
  • Posts: 11
Re: spoken numbers into integer values
« Reply #4 on: February 21, 2021, 08:39:20 PM »
[{TXTNUM:"{CMD}"}]

still not got it. same error.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: spoken numbers into integer values
« Reply #5 on: February 21, 2021, 09:32:51 PM »
Have you read the (linked) documentation on tokens?

Compare the action list of your command to the example in my post, specifically the "Loop Start - Repeat a Certain Number of Times" action's entry. Do you see the difference?

There should only be one set of square brackets wrapping the outer token, which is added as markup to the action list, and is not part of the input for the "Number of times" field.

cargorunner1969

  • Newbie
  • *
  • Posts: 11
Re: spoken numbers into integer values
« Reply #6 on: February 24, 2021, 02:36:26 AM »
i was having trouble reading the text so copy pasted it not seeing the extra items.

thank you so much for your time and attention.