Author Topic: Bug or syntax error?  (Read 7933 times)

zerofox

  • Posts: 4
Bug or syntax error?
« on: June 16, 2016, 05:50:11 PM »
I have the Verity voice pack from HCS; the below scripts are from the default Elite Verity 2.0 profile. 

If I use a command that executes ((Left Panel)) directly (see "Find a docking pad" below), the Navigation screen opens as expected.  If I use a command that wraps it in a conditional (see "Open Left Panel" below), nothing ever happens.  I'd like to know if they've gotten the conditional syntax wrong, or if there might be a bug in the engine.  Thanks!

Spoken command "Open Left Panel":
Code: [Select]
Begin Small Integer Compare : [left-panel-status] Equals 0
    Execute command, '((Left Panel))' (and wait until it completes)
    Set small int (condition) [left-panel-status] value to 1
    Set small int (condition) [right-panel-status] value to 0
    Set small int (condition) [comms-panel-status] value to 0
End Condition - Exit when condition met
Begin Small Integer Compare : [left-panel-status] Equals 1
    Execute command, '((Left Panel))' (and wait until it completes)
    Set small int (condition) [left-panel-status] value to 0
End Condition - Exit when condition met

Spoken command "Find a docking pad":
Code: [Select]
Execute command, '((Left Panel))' (and wait until it completes)
Pause 0.5 seconds
Execute command, '((UI Next))' (and wait until it completes)
Pause 0.3 seconds
Execute command, '((UI Next))' (and wait until it completes)
Pause 0.3 seconds
Execute command, '((UI Accept))' (and wait until it completes)
Pause 0.03 seconds
Execute command, '((UI Down))' (and wait until it completes)
Pause 0.03 seconds
Execute command, '((UI Accept))' (and wait until it completes)
Pause 0.03 seconds
Play random sound (12 items - suppress repeats)
Pause 0.03 seconds
Execute command, '((UI Previous))' (and wait until it completes)
Pause 0.3 seconds
Execute command, '((UI Previous))' (and wait until it completes)
Pause 0.3 seconds
Execute command, '((Left Panel))' (and wait until it completes)

For reference, the ((Left Panel)) command:
Code: [Select]
Press 1 key and hold for 0.03 seconds and release

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Bug or syntax error?
« Reply #1 on: June 16, 2016, 07:19:06 PM »
Spoken command "Open Left Panel":
You have two conditionals, but I'm going to assume you're never setting the "left-panel-status" Small. Unset does not evaluate to anything but "Unset", Gary decided to do it that way.

So your conditionals don't execute, because the value is neither 0 or 1(which, if you don't need anything but those two, would be better served being a Boolean).

zerofox

  • Posts: 4
Re: Bug or syntax error?
« Reply #2 on: June 16, 2016, 07:25:09 PM »
From the docs:
Quote
If a variable that is being compared is NOT SET, the comparison will always result as false.  So, if 'My Condition 1' is not set, and you try to compare it to 0 by setting the operator as, 'not equal to', the result will be false and the code will continue after the end block.

This tells me, if I'm reading it correctly, that an unset variable will always report false (which I would assume equates to 0).  This is in Voice Attack 1.8.4 (non-beta).
« Last Edit: June 16, 2016, 07:29:28 PM by zerofox »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Bug or syntax error?
« Reply #3 on: June 16, 2016, 07:30:53 PM »
Interestingly, the script below NEVER fires the space buttonpress.

Yeah...You're setting an Int, and checking a Small...


The documentation is a work in progress, so it's best to verify for yourself:
Code: [Select]
Begin Small Integer Compare : [Test] Equals 0
    Write '[Red] Test is zero' to log
End Condition
Begin Small Integer Compare : [Test] Equals 1
    Write '[Red] Test is one' to log
End Condition
Set small int (condition) [test] value to 0
Begin Small Integer Compare : [Test] Equals 0
    Write '[Blue] Test is zero' to log
End Condition
Begin Small Integer Compare : [Test] Equals 1
    Write '[Blue] Test is one' to log
End Condition
Set small int (condition) [test] value to 1
Begin Small Integer Compare : [Test] Equals 0
    Write '[Purple] Test is zero' to log
End Condition
Begin Small Integer Compare : [Test] Equals 1
    Write '[Purple] Test is one' to log
End Condition
Set small int (condition) [test] value to [Not Set]
Red will never fire, blue will be zero, purple will be one.

zerofox

  • Posts: 4
Re: Bug or syntax error?
« Reply #4 on: June 16, 2016, 07:34:08 PM »
Yeah, I saw that after I posted my test case.  Still, though, if

Quote
If a variable that is being compared is NOT SET, the comparison will always result as false.

indicates that a comparison to a non-existent variable will always be false (rather than a non-existent variable evaluating to a falsy value), then the remainder of the paragraph in the docs is extraneous and confusing.

zerofox

  • Posts: 4
Re: Bug or syntax error?
« Reply #5 on: June 16, 2016, 07:41:13 PM »
Either way, thanks for your help.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Bug or syntax error?
« Reply #6 on: June 16, 2016, 07:45:16 PM »


This topic has the relevant discussion. Apparently it's in the works to give variable types default values rather than "Unset", but no ETA.
« Last Edit: June 23, 2016, 09:59:52 PM by Gary »