Author Topic: Probably simple, but I can't seem to get it right  (Read 2134 times)

jcdick1

  • Jr. Member
  • **
  • Posts: 59
Probably simple, but I can't seem to get it right
« on: January 08, 2021, 09:26:07 PM »
I'm trying to convert a DEC variable that goes six decimal places deep to a whole number, and have the text-to-speech read that whole number back to me in response to a voice command.  I figured it would be a conversion from DEC to INT, and then if necessary, INT to TXT.  But the response just reads back the actual name of the variable instead of its value, or says "not set".  I'm not sure what I'm doing wrong.  I've tried with and without {} in the source and target variable name boxes, with and without DEC: and INT: in the names, etc.

I've also tried setting a new DEC variable from the source DEC variable, rounded to 0 decimal places.  But I still just get the text-to-speech reading back the variable name.
 
Any help is appreciated.
« Last Edit: January 08, 2021, 10:22:43 PM by jcdick1 »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Probably simple, but I can't seem to get it right
« Reply #1 on: January 08, 2021, 10:29:53 PM »
What does your command currently look like? Right-click the action list, choose "Copy All as Text", and paste into a code block (click the # button) here.


Have you read the documentation on tokens and variables? Press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer.

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

jcdick1

  • Jr. Member
  • **
  • Posts: 59
Re: Probably simple, but I can't seem to get it right
« Reply #2 on: January 08, 2021, 11:10:35 PM »
Code: [Select]
Set decimal [{thruster health}] value to the converted value of {DEC:Ship thrusters health} (round to 0 decimal places)
Append, '{thruster health}' to file 'C:\Users\user\Documents\health.txt'
Say, '[The {TXT:Ship name}'s' or 'the ship's] thrusters are at {thruster health} percent [health].'

I added the file writing to confirm that the value was being passed as expected.  I think I may be confused on when you need - or if you even do need - to add the DEC: or TXT: or INT: prefix to a variable.

And the final word is in brackets because I was hoping it would be seen as optional to speak it or just stop at "percent" in the spoken response.  But it doesn't seem to work that way, either.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Probably simple, but I can't seem to get it right
« Reply #3 on: January 08, 2021, 11:20:58 PM »
Instead of trial and error, reading the documentation is the recommended way to gain an understanding of these concepts for yourself.


Have a look at the "'Say Something with Text-To-Speech'" section of VoiceAttackHelp.pdf  (starting on page 49); This will show you why just placing brackets by itself does not make a section optional.

The variables and tokens summed up topic linked previously attempts to explain the basic concepts of those features, and tries to clarify what requires curly braces or other markup, and what doesn't.

jcdick1

  • Jr. Member
  • **
  • Posts: 59
Re: Probably simple, but I can't seem to get it right
« Reply #4 on: January 09, 2021, 07:51:25 PM »
Thanks for the pointers.  I did finally get it working.