Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Comparing boolean values implicitly is not working

Featured Replies

 

Either of these should flip the boolean value of (L:SW_SOV_PANELS_Door_Baggage, Bool)
This does not work
(A:SIM ON GROUND, Bool) 1 == if{
(L:SW_SOV_CONFIG_Simple_Openings, Bool) 0 == if{

IMPLICIT

(L:SW_SOV_PANELS_Latch_Baggage_1_1, Bool) (L:SW_SOV_PANELS_Latch_Baggage_2_1, Bool) and


if{
(L:SW_SOV_PANELS_Door_Baggage, Bool) ! (>L:SW_SOV_PANELS_Door_Baggage, Bool) } } }

This works
(A:SIM ON GROUND, Bool) 1 == if{
(L:SW_SOV_CONFIG_Simple_Openings, Bool) 0 == if{

EXPLICIT

(L:SW_SOV_PANELS_Latch_Baggage_1_1, Bool) 0 == (L:SW_SOV_PANELS_Latch_Baggage_2_1, Bool) 0 == and


if{
(L:SW_SOV_PANELS_Door_Baggage, Bool) ! (>L:SW_SOV_PANELS_Door_Baggage, Bool) } } }

WW5130.png

| i7-14700KF - 4080 SUPER | 32 GB RAM | Win 11 Pro | HC Bravo | AAO | StreamDeck | 

  • Commercial Member

From my perspective, the two yellow scripts in your post do the exact opposite from each other. They cannot produce the same results.

2 hours ago, mrm0508 said:

(L:SW_SOV_PANELS_Latch_Baggage_1_1, Bool) (L:SW_SOV_PANELS_Latch_Baggage_2_1, Bool) and

This script returns true when both LVars are true (= have a value of 1.0, Lvars are always Numbers)
"1 1 and" results in a value of 1.0 (true)

2 hours ago, mrm0508 said:

(L:SW_SOV_PANELS_Latch_Baggage_1_1, Bool) 0 == (L:SW_SOV_PANELS_Latch_Baggage_2_1, Bool) 0 == and

And this script is the exact opposite. You query explicitly if both LVars are false (= have a value of 0.0)

Edited by Lorby_SI

LORBY-SI

  • Commercial Member

On a side note, LVars are always numbers. TMBK, giving them a different unit, like "Bool", has no effect. You can just as well stick with "Number". Just make sure that the value range of the LVar is actually "0 or 1". In most cases, LVars have much larger value ranges, like 0 to 30 or 0 to 100. They are often used to control animations, and their value represents the "frame" that the animation is currently at.

Another note: For AAO "0" always means "false". But many operators tolerate "true" as being "not 0".

Edited by Lorby_SI

LORBY-SI

  • Author

These variables are compartment latches, they are either closed (0) or open (1), I am trying to check if they are all open prior to trying to open the compartment (L:SW_SOV_PANELS_Door_Baggage, Bool) which also is either closed (0) or open (1). So, if both latches are closed (both 0) the door won't open and if they are both open, then the door can open. So, I am checking to see if both latches are the same (1 or 0) with "and" and that doesn't work, it only works if I explicitly use "0 ==" or "1 ==" in the expression. It great simplifies the code if I can just use the implicit version.

Here is the mousrects code for the clickspot I am working on. This code does not run in AAO as written:


(A:SIM ON GROUND, Bool) 1 == if{ 
	(L:SW_SOV_CONFIG_Simple_Openings, Bool) 0 == if{ 
		(L:SW_SOV_PANELS_Latch_Baggage_1_1, bool) 
		(L:SW_SOV_PANELS_Latch_Baggage_2_1, bool) 
		(L:SW_SOV_PANELS_Latch_Baggage_3_1, bool) 
		(L:SW_SOV_PANELS_Latch_Baggage_4_1, bool) 
		(L:SW_SOV_PANELS_Handle_Baggage, bool) 
		and and and and if{ 
			(L:SW_SOV_PANELS_Door_Baggage) ! (>L:SW_SOV_PANELS_Door_Baggage) 
		} 
	} 
	els{ 
		(L:SW_SOV_PANELS_Door_Baggage) ! (>L:SW_SOV_PANELS_Door_Baggage) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_1_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_2_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_3_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_4_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Handle_Baggage) 
	} 
} 

This is what I did that worked:
(A:SIM·ON·GROUND,·Bool)·1·==·if{·(L:SW_SOV_PANELS_Door_Baggage,·bool)·0·==·if{·(L:SW_SOV_PANELS_Latch_Baggage_1_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_1_1,·Number)·(L:SW_SOV_PANELS_Latch_Baggage_2_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_2_1,·Number)·(L:SW_SOV_PANELS_Latch_Baggage_3_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_3_1,·Number)·(L:SW_SOV_PANELS_Latch_Baggage_4_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_4_1,·Number)·(WAIT:3000)·(L:SW_SOV_PANELS_Handle_Baggage,·Number)·!·(>L:SW_SOV_PANELS_Handle_Baggage,·Number)·(WAIT:1000)·(L:SW_SOV_PANELS_Door_Baggage,·bool)·!·(>L:SW_SOV_PANELS_Door_Baggage,·bool)}}

·(L:SW_SOV_PANELS_Door_Baggage,·bool)·1·==·if{·(L:SW_SOV_PANELS_Door_Baggage,·bool)·!·(>L:SW_SOV_PANELS_Door_Baggage,·bool)·(WAIT:5000)·(L:SW_SOV_PANELS_Handle_Baggage,·Number)·!·(>L:SW_SOV_PANELS_Handle_Baggage,·Number)·(WAIT:1000)·(L:SW_SOV_PANELS_Latch_Baggage_1_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_1_1,·Number)·(L:SW_SOV_PANELS_Latch_Baggage_2_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_2_1,·Number)·(L:SW_SOV_PANELS_Latch_Baggage_3_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_3_1,·Number)·(L:SW_SOV_PANELS_Latch_Baggage_4_1,·Number)·!·(>L:SW_SOV_PANELS_Latch_Baggage_4_1,·Number)·}

Edited by mrm0508
Added code I used that worked to toggle the baggage door

WW5130.png

| i7-14700KF - 4080 SUPER | 32 GB RAM | Win 11 Pro | HC Bravo | AAO | StreamDeck | 

  • Commercial Member
14 hours ago, mrm0508 said:

This code does not run in AAO as written

Correct. Behavior code must always be adapted for AAOs RPN dialect. Most importantly, all LVars must have a unit (like ,Number). Otherwise AAO will treat them as internal, and will not sync them with the simulator.

LORBY-SI

  • Commercial Member
15 hours ago, mrm0508 said:

So, I am checking to see if both latches are the same (1 or 0) with "and" and that doesn't work

The boolean "and" only checks if both vars are true/1. It does not check if they are the same, that would be the "=="

'1 1 and' => true/1
'0 0 and' => false/0
'1 0 and' => false/0
'0 1 and' => false/0

********

'1 1 ==' => true/1
'0 0 ==' => true/1
'1 0 ==' => false/0
'0 1 ==' => false/0

Edited by Lorby_SI

LORBY-SI

  • Commercial Member

There is another problem that AAO will have with the behavior script. AAOs RPN parser does not propagate variable changes inside the same script. I've altered the code it so it uses a register instead:

(A:SIM·ON·GROUND,·Bool)·1·==·if{·
·(L:SW_SOV_CONFIG_Simple_Openings,·Number)·0·==·if{·
··(L:SW_SOV_PANELS_Latch_Baggage_1_1,·Number)·
··(L:SW_SOV_PANELS_Latch_Baggage_2_1,·Number)·
··(L:SW_SOV_PANELS_Latch_Baggage_3_1,·Number)·
··(L:SW_SOV_PANELS_Latch_Baggage_4_1,·Number)·
··(L:SW_SOV_PANELS_Handle_Baggage,·Number)·
··and·and·and·and·if{·
···(L:SW_SOV_PANELS_Door_Baggage,·Number)·!·(>L:SW_SOV_PANELS_Door_Baggage,·Number)·
··}·
·}·
·els{·
··(L:SW_SOV_PANELS_Door_Baggage,·Number)·!·s0·
··l0·(>L:SW_SOV_PANELS_Door_Baggage,·Number)·
··l0·(>L:SW_SOV_PANELS_Latch_Baggage_1_1,·Number)·
··l0·(>L:SW_SOV_PANELS_Latch_Baggage_2_1,·Number)·
··l0·(>L:SW_SOV_PANELS_Latch_Baggage_3_1,·Number)·
··l0·(>L:SW_SOV_PANELS_Latch_Baggage_4_1,·Number)·
··l0·(>L:SW_SOV_PANELS_Handle_Baggage,·Number)·
·}·
}·

Edited by Lorby_SI

LORBY-SI

  • Commercial Member

To explain this a bit.

The biggest problem with the behavior code is this part:

		(L:SW_SOV_PANELS_Door_Baggage) ! (>L:SW_SOV_PANELS_Door_Baggage) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_1_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_2_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_3_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Latch_Baggage_4_1) 
		(L:SW_SOV_PANELS_Door_Baggage) (>L:SW_SOV_PANELS_Handle_Baggage) 
  • For one, none of the LVars has a unit - which means that AAO will treat them as internal vars, and never send them to the sim. The solution is to add at least the default ", Number"

  • Second, the AAO RPN parser works a little differently than the sim. In the first line, the SW_SOV_PANELS_Door_Baggage is changed. In the subsequent lines, this new value is written to a bunch of other LVars. The AAO parser doesn't work like that, it will replace all occurences of SW_SOV_PANELS_Door_Baggage with its current value before executing the script. As a result, all the LVars will receive the OLD value of SW_SOV_PANELS_Door_Baggage, not the new one.
    One solution I have outlined above, and that is using registers, which are updated at runtime.
    Another solution would be to apply the "!" operation to all assignments of the SW_SOV_PANELS_Door_Baggage:

    		(L:SW_SOV_PANELS_Door_Baggage, Number) ! (>L:SW_SOV_PANELS_Door_Baggage, Number) 
    		(L:SW_SOV_PANELS_Door_Baggage, Number) ! (>L:SW_SOV_PANELS_Latch_Baggage_1_1, Number) 
    		(L:SW_SOV_PANELS_Door_Baggage, Number) ! (>L:SW_SOV_PANELS_Latch_Baggage_2_1, Number) 
    		(L:SW_SOV_PANELS_Door_Baggage, Number) ! (>L:SW_SOV_PANELS_Latch_Baggage_3_1, Number) 
    		(L:SW_SOV_PANELS_Door_Baggage, Number) ! (>L:SW_SOV_PANELS_Latch_Baggage_4_1, Number) 
    		(L:SW_SOV_PANELS_Door_Baggage, Number) ! (>L:SW_SOV_PANELS_Handle_Baggage, Number) 
    

    I know, this doesn't really make sense. It is one of those things that you just have to know about AAO. It has been implemented this way at the beginning. Over the years everybody worked around it in code. Now it is too late to change it, because that change would probably invalidate a large amount of existing scripts.

Edited by Lorby_SI

LORBY-SI

  • Author

Wow, thank you so much for expanding on this. I have little knowledge of how the sim and AAO treat RPN differently, I end up with a lot of trial and error.....mostly error :) Much appreciated.

WW5130.png

| i7-14700KF - 4080 SUPER | 32 GB RAM | Win 11 Pro | HC Bravo | AAO | StreamDeck | 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.