• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Eureka?? Not yet :(

Zeiten

Resource contributor
Messages
444
Country
norway
The XML stuff is hard to learn..

Thought I finally had figured it, but then reality kicked me in the ***.

Trying to code the apu so that a master switch needs to be turned on in order for the apu start button to work.

What this code "tells me" is that when left click;

if the value of (L:fe apu on, enum) and (L:fe apu master on, bool) is 1 the (K:APU_STARTER) kicks in, and if the value was 0 for the (L:fe apu master on, bool) the (L:fe apu on, enum) switch would return to 0 and the apu will not start.

But whats happening is that when I press Apu on the frigging master switch also moves (and of course the apu starts).

It's seems that the sim and I have some disagreements, but will let the sim have the benefits of doubt.


Code:
<PartInfo>
    <Name>fe_apu_on</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:fe apu on, enum) 50 *
        </Code>
        <Lag>300</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Start Apu</TooltipText>
	  <MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
      <CallbackCode>
			(M:Event) 'LeftSingle' scmp 0 ==
			1 (&gt;L:fe apu on, enum) 1 (&gt;L:fe apu master on,bool)
			if{ (&gt;K:APU_STARTER) } els{ (&gt;L:fe apu on, enum) }
			
			(M:Event) 'LeftRelease' scmp 0 ==
			if{ 0 (&gt;L:fe apu on, enum) }
			
			(M:Event) 'LeftDrag' scmp 0 == 
			if{ 0 (&gt;L:fe apu on, enum) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
Code:
			(M:Event) 'LeftSingle' scmp 0 ==
			(L:fe apu master on,bool) 1 == and
			(L:fe apu on, enum)  1 == and
			if{ (>K:APU_STARTER) } els{ 0 (>L:fe apu on, enum) }

You are confusing "read the variable" and "set the variable" syntax...

(L:SomeVariable,enum) n == is "read the variable" syntax.

n (>L:SomeVariable,enum) is "set the variable" syntax.
 
Thanks for the explanation of the read and set difference in syntax.

Unfortunately it still does not work :(

Code:
       <PartInfo>
    <Name>fe_apu_master_on</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:fe apu master on,bool) 50 *
        </Code>
        <Lag>200</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
       <Cursor>Hand</Cursor>
        <MouseFlags>LeftSingle</MouseFlags>
        <CallbackCode>
          (L:fe apu master on,bool) ! (&gt;L:fe apu master on,bool)
        </CallbackCode>
    </MouseRect>
  </PartInfo>


Code:
      <PartInfo>
    <Name>fe_apu_on</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:fe apu on, enum) 50 *
        </Code>
        <Lag>300</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Start Apu</TooltipText>
	  <MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
      <CallbackCode>
			(M:Event) 'LeftSingle' scmp 0 ==
			(L:fe apu master on,bool) 1 == and
			(L:fe apu on, enum) 1 == and
			if{ (&gt;K:APU_STARTER) } els{ 0 (&gt;L:fe apu on, enum) }
			
			(M:Event) 'LeftRelease' scmp 0 ==
			if{ 0 (&gt;L:fe apu on, enum) }
			
			(M:Event) 'LeftDrag' scmp 0 == 
			if{ 0 (&gt;L:fe apu on, enum) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
Thanks for the explanation of the read and set difference in syntax.

Unfortunately it still does not work :(

It seems you define (L:fe apu on, enum) as the current position of the start button, so when button is pressed (L:fe apu on, enum) = 1 and when released (L:fe apu on, enum) = 0; the position of the master start has influence only in the START event to be fired. Then a suitable code could be:

Code:
<CallbackCode>
       (M:Event) 'LeftSingle' scmp 0 ==
       if{ 1 (>L:fe apu on, enum)
            (L:fe apu master on,bool)
            if{   (>K:APU_STARTER)    }
           }
       els{  0 (>L:fe apu on, enum) }
</CallbackCode>
Now, if you need to keep the start button in the ON (pressed) position while the apu starts, some lines of code should be added to the script.

Tom
 
Thanks, Tom. I was so focused on the syntax I didn't pay enough attention to the actual logic...

Of course my example would never work, since (L:fe apu on, enum) will never be true (1) until the button is clicked on! :o
 
Back
Top