• 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.

Custom VC Switch

Messages
114
I am in need of some help.

I want to make a custom ALL LIGHTS ON/OFF switch, and tried the code below, following another thread on these forums.

First, I used

<PartInfo>
<Name>switch_ALL_light</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:MySwitch,bool) 50 * (* we multiply the L:variable by 50 *)
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<CallbackCode>
(L:MySwitch,bool) ! (>L:MySwitch,bool) (* this toggles off/on *)
</CallbackCode>
</MouseRect>
</PartInfo>

the switch then animates at the first CLICK to theON position, but it stays on. It never switches off. Even when I click on it

Second, when i try to add the EVENT ID,

ALL_LIGHTS_TOGGLE

so I get

<PartInfo>
<Name>switch_ALL_light</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:MySwitch,bool) 50 * (* we multiply the L:variable by 50 *)
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<CallbackCode>
(L:MySwitch,bool) ! (>L:MySwitch,bool) (* this toggles off/on *)
</CallbackCode>
<EventID>ALL_LIGHTS_TOGGLE</EventID>
</MouseRect>
</PartInfo>

Then, it all stops working

What am i doing wroing?
 
Try moving the command inside the Callback Code tags

Code:
<CallbackCode>
(L:MySwitch,bool) ! (>L:MySwitch,bool) (* this toggles [COLOR="Red"]the .bmp [/COLOR]off/on *)
(>K:ALL_LIGHTS_TOGGLE)  (* this operates every click *)
</CallbackCode>

Ted.
 
Try moving the command inside the Callback Code tags

Code:
<CallbackCode>
(L:MySwitch,bool) ! (>L:MySwitch,bool) (* this toggles [COLOR="Red"]the .bmp [/COLOR]off/on *)
(>K:ALL_LIGHTS_TOGGLE)  (* this operates every click *)
</CallbackCode>

Ted.

Ted

Whilst that does work, and on initial aircraft load, the switch can be pressed, and all the lights turn on, it does not allow me to then then turn it off

Once the switch is on, the mouserect seems to be inactive, and no 'hand' is visable on the switch, and it fails to turn off
 
Do you delete the annotations when using the code...?

not as far as I can tell

this is my current code

<PartInfo>
<Name>switch_ALL_light</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:MySwitch,bool) 50 * (* we multiply the L:variable by 50 *)
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<CallbackCode>
(L:MySwitch,bool) ! (>L:MySwitch,bool) (* this toggles the .bmp off/on *)
(>K:ALL_LIGHTS_TOGGLE) (* this operates every click *)
</CallbackCode>
</MouseRect>
</PartInfo>

As mentioned, it works, first time, switches on, but cannot be turned off
 
Code:
<PartInfo>
<Name>switch_ALL_light</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:MySwitch,bool) 50 *
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<CallbackCode>
(L:MySwitch,bool) ! (&gt;L:MySwitch,bool)
(>K:ALL_LIGHTS_TOGGLE)
</CallbackCode>
</MouseRect>
</PartInfo>

Try this.


Annotations in XML code are properly formatted this way, by the way:
Code:
<!-- Blah blah blah -->
 
This works on my Don in FS2004 as I do not have FSX. I just changed the capitalisation of the tag names to suit the MakeMDL.parts file.
Code:
<part>
     <name>switch_ALL_light</name>
     <!-- AnimLength>50</AnimLength -->
     
     <animation>
          <parameter>
               <code>
                    (L:MySwitch,bool) 50 *
               </code>
          </parameter>
     </animation>
     
     <mouserect>
          <cursor>Hand</cursor>
          <callback_code>
               (L:MySwitch,bool) ! (>L:MySwitch,bool) (>K:ALL_LIGHTS_TOGGLE)
          </callback_code>
     </mouserect>
     
</part>
Ted.
 
Code:
<PartInfo>
<Name>switch_ALL_light</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:MySwitch,bool) 50 *
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<CallbackCode>
(L:MySwitch,bool) ! (&gt;L:MySwitch,bool)
(>K:ALL_LIGHTS_TOGGLE)
</CallbackCode>
</MouseRect>
</PartInfo>

Try this.


Annotations in XML code are properly formatted this way, by the way:
Code:
<!-- Blah blah blah -->

does not work. AS before, I can operate the switch ONCE, then never again
 
Try a "Reset Scale" and that other reset thing on the switch model.


I can't spot any flaws in the code, so it's quite baffling.
 
Is your switch animated to KF 50? If its animated to 100, that 'might' cause an issue, but only in animation. For instance, if you animated the switch to 100, and this one is set to 50, then it will animate half the distance and stop.


That shouldn't make it work one way though.


Also, if the command key is to turn on the lights, it will only turn them on. Toggle will work them on/off though, so that too is fine...


odd...

EDIT: Are the lights turning on and off?
EDIT2: Do you have an invisible switch that operates any lights? This could be stepping on the code, causing this to occur.
EDIT3: Double check your top line code (top of the code section) to make sure all is proper there. (where the GUID is written at)

Why not re-write a new switch from existing code, redo your coding into the new block, comment out your malfunctioning block and try again. Sometimes when this happens to me, and I cannot find the issue, doing this fixes it. Something so small that I just cant find the issue. Making a new code block from scratch fixes it.
 
Last edited:
tried the reset scale, no effect

the switch is animated to 50, as per the code. On operation, it does switch on the lights switch on ok. But once one, the switch will not operate. AS mentioned, when I hover over the switch, i do not even get the HAND cursor, that I get on first operation, so it is as if there is NO switch there anymore:confused:
 
Back
Top