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

FS2004 Custom Animation of a Function Button (SOLVED)

Messages
1,451
Country
mexico
Hello lads

I am wondering if you can lend me a hand with a custom animation. I spend three weeks working with this problem before asking for help. Belive me, I've read all I could in this regard and what have been said on several posts.

Well, there we go with the idea:
If I am correct, this code is for a part that behaves like a button which toggles "on/off" . The variable controlling it, came from Don Khun's Garmin 330GTX. I've use a similiar code with other 3d items and it worked:

HTML:
 <part>
      <name>toggle_garmin330gtx_ssbutt</name>
          <animation>
            <parameter>
              <code>
                (L:SS,bool) 100 *
              </code>
            </parameter>
          </animation>
          <mouserect>
            <cursor>Hand</cursor>
            <tooltip_text>Start/Stop</tooltip_text>
            <callback_code>
              (L:SS,bool) ! (&gt;L:SS,bool)
            </callback_code>
          </mouserect>
   </part>

Now, he wrote in his Garmin's code a logic which toggles 5 functions using a single function button:

HTML:
<Element>
        <Position X="412" Y="23"/>
          <Select>
          <Value>(L:PrAlt,bool)</Value>
          <Case Value="0">
           <Image Name="Funcbutt_out.bmp" ImageSizes="30,20"/>
           </Case>
           <Case Value="1">
           <Image Name="Funcbutt_in.bmp" ImageSizes="30,20"/>
           </Case>
            </Select>
    </Element>

    <Element>
        <Position X="412" Y="23"/>
        <Select>
        <Value>(L:Flt,bool)</Value>
        <Case Value="0">
         <Image Name="Funcbutt_out.bmp" ImageSizes="30,20"/>
         </Case>
         <Case Value="1">
         <Image Name="Funcbutt_in.bmp" ImageSizes="30,20"/>
         </Case>
          </Select>
    </Element>

   <Element>
        <Position X="412" Y="23"/>
        <Select>
        <Value>(L:DAlt,bool)</Value>
        <Case Value="0">
         <Image Name="Funcbutt_out.bmp" ImageSizes="30,20"/>
         </Case>
         <Case Value="1">
         <Image Name="Funcbutt_in.bmp" ImageSizes="30,20"/>
         </Case>
          </Select>
    </Element>

       <Element>
          <Position X="412" Y="23"/>
          <Select>
          <Value>(L:CUp,bool)</Value>
          <Case Value="0">
           <Image Name="Funcbutt_out.bmp" ImageSizes="30,20"/>
           </Case>
           <Case Value="1">
           <Image Name="Funcbutt_in.bmp" ImageSizes="30,20"/>
           </Case>
            </Select>
    </Element>

        <Element>
        <Position X="412" Y="23"/>
        <Select>
        <Value>(L:AltM,bool)</Value>
        <Case Value="0">
         <Image Name="Funcbutt_out.bmp" ImageSizes="30,20"/>
         </Case>
         <Case Value="1">
         <Image Name="Funcbutt_in.bmp" ImageSizes="30,20"/>
         </Case>
          </Select>
    </Element>

After a lot of time trying to do it, I think I grasp the key idea here:
http://www.fsdeveloper.com/forum/threads/one-switch-3-commands-one-at-a-time.435010/#post-720933

My goal is to built a 3D function button that cycles itself 5 steps; it is a mixed idea combining the first code and the one from Delivery Guy's code in the last thread. L:330gtx_func_swap,bool will be changing its state on each click; so I need to link in some way the variable L:330gtx_func_inc to initiate a loop from 0 to 4 that swap the functions in the nested 'if' conditions. My version to that is this:

HTML:
 <part>
      <name>toggle_garmin330gtx_funcbutt</name>
          <animation>
            <parameter>
                <code>
                  (L:330gtx_func_swap,bool) 100 *
                </code>
            </parameter>
          </animation>
          <mouserect>
            <cursor>Hand</cursor>
            <tooltip_text>FUNC</tooltip_text>
            <callback_code>
              (L:330gtx_func_swap,bool) ! (&gt;L:330gtx_func_swap,bool)
              <!-- Counter up in a cycle??? -->
              (L:330gtx_func_inc,enum) ++ 4 % (>L:330gtx_func_inc,enum)
                    (L:330gtx_func_inc,enum, enum) 0 ==
                          if{ (L:PrAlt,bool) ! (&gt;L:PrAlt,bool) }
                    (L:330gtx_func_inc,enum, enum) 1 ==
                          if{ (L:Flt,bool) ! (&gt;L:Flt,bool) }
                    (L:330gtx_func_inc,enum, enum) 2 ==
                          if{ (L:DAlt,bool) ! (&gt;L:DAlt,bool) }
                    (L:330gtx_func_inc,enum, enum) 3 ==
                          if{ (L:CUp,bool) ! (&gt;L:CUp,bool) }
                    (L:330gtx_func_inc,enum, enum) 4 ==
                          if{ (L:AltM,bool) ! (&gt;L:AltM,bool) }
            </callback_code>
          </mouserect>
   </part>

Nevertheless, I am not able to make this work. If I undestood well, the line
(L:330gtx_func_inc,enum) ++ 4 % (>L:330gtx_func_inc,enum) will construct a counter up from 0 to 4 and start all over again.

Errata:
To understand the loop code (newbies like me), please read:
http://www.fsdeveloper.com/wiki/index.php?title=XML:_Increment_Variable_w/Modulo_Reset

I guess we need to thank to Fr. Leaming for this explanation.

Any help would be very appreciated.

In advance,
Thank you.
Sergio.
 
Last edited:
Nevermind folks

I have done some more tests, and the garmin GTX330 do nothing when I push de 3d gauge buttons. Nevertheless, I can see the 2d panel reacting when I hit a key on the 3d keyboard o_O o_O o_O o_O o_O

Just did an educated guess, I fixed the planar in the same $P2 texture. In one region of that texture, if I move the 2d gauge locations I would only see the screen. Other region within the same texture, is on a flat surface on the central console; so, in theory, I would see if the garmin really did something.
And it did, nevertheless, all bloody GVars in the 2d Garmin code will never get me this to work. So, I drop this for good.

Garmin330_issue.jpg


When I said "works fine", it is regarding all buttons except the FUNC button.

Thanks any way,
Sergio.
:(
 
Do you want to have the button pop out after pressing it?

If so, you'll need a controller (non-animated, untextured polygon with a visibility code) and a timer function.

Code:
<part>
<name>button_controller</name>
<visible_in_range>
<parameter>
<code>
(L:330gtx_func_swap, number) 0 &gt;
if{ (L:330gtx_func_swap, number) -- 0 max (>L:330gtx_func_swap, number)
}
</code>
</parameter>
<minvalue>1</minvalue>
<maxvalue>1</maxvalue>
</visible_in_range>
</part>

This will count down from whatever number you specify in the clickspot.


Code:
 <part>
      <name>toggle_garmin330gtx_funcbutt</name>
          <animation>
            <parameter>
                <code>
                  (L:330gtx_func_swap, number) 30 / near 100 *
                </code>
            </parameter>
          </animation>
          <mouserect>
            <cursor>Hand</cursor>
            <tooltip_text>FUNC</tooltip_text>
            <callback_code>
              30 (&gt;L:330gtx_func_swap, number)
              <!-- Counter up in a cycle??? -->
              (L:330gtx_func_inc,enum) ++ 4 % (>L:330gtx_func_inc,enum)
                    (L:330gtx_func_inc,enum, enum) 0 ==
                          if{ (L:PrAlt,bool) ! (&gt;L:PrAlt,bool) }
                    (L:330gtx_func_inc,enum, enum) 1 ==
                          if{ (L:Flt,bool) ! (&gt;L:Flt,bool) }
                    (L:330gtx_func_inc,enum, enum) 2 ==
                          if{ (L:DAlt,bool) ! (&gt;L:DAlt,bool) }
                    (L:330gtx_func_inc,enum, enum) 3 ==
                          if{ (L:CUp,bool) ! (&gt;L:CUp,bool) }
                    (L:330gtx_func_inc,enum, enum) 4 ==
                          if{ (L:AltM,bool) ! (&gt;L:AltM,bool) }
            </callback_code>
          </mouserect>
   </part>

The clickspot sets the countdown to 30 and your controller will count down. The button will be depressed for 15 cycles (since 15/30 = 0.5 which is rounded up to 1 and multiplied by 100), which equates to about half a second at a framerate of 30 FPS. You might want to play with the numbers.

This might look a bit clumsy but it's the only solution I can come up with at the moment.
 
Hello Björn

Thanks for the quick and detailed reply! However, I don't know how to overcome the GVars in the 2d gauge. I tried to change them by using Lvars but I can't make them to reset as the Gvars do. I guess that's the biggest problem to solve now. I was so angry, that for a moment crossed in my mind to delete the whole Garmin GTX330 dictionary part...:banghead::banghead::banghead:

Fortunatelly, I didn't and also have the animations in the vc (well... a sort of). I guees I will need to include some lag tag on the remaining buttons, because I can't see them to switch in the three positions like I do in Gmax. Will try your solution as soon as I can change Gvars for Lvars in a suitable way and my brain cools down a little...:confused::confused::confused:

Thank you very much my friend.
Have a nice day.
Sergio.
 
Last edited:
Hi lads

Still no joy... I am testing with only two buttons to see if there's any response in the 2D gauge. The weired thing is I still can see the 2D gauge buttons responding to the mouse clicks on the VC; nevertheless the Garmin doesn't turn on or off. :banghead::banghead::banghead:
The mouuse areas in the 2D gauge are:
HTML:
   <Area Left="70" Right="90" Top="20" Bottom="40">
        <Tooltip>%POWER ON BUTTON%{end}</Tooltip>
      <Cursor Type="Hand"/>
       <Click>(L:ona,bool) ! (>L:ona,bool) 0 (>L:prsralt,bool) 0 (>L:stdby,bool) (G:Var1) 0 == if{ 3 (>G:Var1) + (P:Local Time, seconds) 3 + (>G:Var2) } els{ 1 (>G:Var1) }</Click>
      </Area>


   <Area Left="90" Right="110" Top="40" Bottom="60">
        <Tooltip>%POWER OFF BUTTON%{end}</Tooltip>
      <Cursor Type="Hand"/>
       <Click>0 (>G:Var1) (L:off,bool) ! (>L:off,bool) 0 (>L:prsralt,bool)</Click>
      </Area>

Now, my attempt to make it work in the VC:
HTML:
<part>
    <name>bell_429_gtx330_on</name>
        <animation>
        <parameter>
        <code>(L:GTX330On,enum) 50 *</code>
        <lag>500</lag>
        </parameter>
        </animation>
        <mouserect>
            <cursor>Hand</cursor>
            <tooltip_text>Power ON</tooltip_text>
            <mouse_flags>LeftSingle+RightSingle+LeftRelease+RightRelease</mouse_flags>
            <callback_code>
                (M:Event) 'LeftSingle' scmp 0 == if{ 1 (&gt;L:GTX330On,enum)
                                  (L:ona,bool) ! (>L:ona,bool) 0 (>L:prsralt,bool) 0 (>L:stdby,bool) (G:Var1) 0 == if{ 3 (>G:Var1) + (P:Local Time, seconds) 3 + (>G:Var2) } els{ 1 (>G:Var1) } }
                (M:Event) 'LeftRelease' scmp 0 == if{ 0 (&gt;L:GTX330On,enum) }
            </callback_code>
        </mouserect>
</part>

<part>
    <name>bell_429_gtx330_off</name>
        <animation>
        <parameter>
        <code>(L:GTX330Off,enum) 50 *</code>
        <lag>500</lag>
        </parameter>
        </animation>
        <mouserect>
            <cursor>Hand</cursor>
            <tooltip_text>Power OFF</tooltip_text>
            <mouse_flags>LeftSingle+RightSingle+LeftRelease+RightRelease</mouse_flags>
            <callback_code>
                (M:Event) 'LeftSingle' scmp 0 == if{ 1 (&gt;L:GTX330Off,enum)
                                  0 (>G:Var1) (L:off,bool) ! (>L:off,bool) 0 (>L:prsralt,bool) }
                (M:Event) 'LeftRelease' scmp 0 == if{ 0 (&gt;L:GTX330Off,enum) }
            </callback_code>
        </mouserect>
</part>

As an experiment, I deleted all Mouse entries in the 2d gauge and the result is the same... the 2d buttons are flickering but no actions taken. :mad::mad::mad:

I am guessing the '&gt;' would be better than '>'

Any idea to solve this would be super nice:)
Sergio.
 
Last edited:
What actually turns the Garmin off and on?

I have some questions about your code, but I don't know if it will help you any...

In this line:

Code:
if{ 3 (>G:Var1) + (P:Local Time, seconds) 3 + (>G:Var2) } els{ 1 (>G:Var1) }

I assumed that when you loaded 3 into (G:Var1) the values were removed from the stack, so I don't know what the + sign after (G:Var1) would do? Is that not true?

And do you need a space after the closing } bracket?
 
Hello Tom

HTML:
'L:ona,bool' controls the On action and 'L:off,bool' do the same for OFF.

Thank you for your observations. Will try to fix those.
All the best,
Sergio.
:wave:
 
Last edited:
Sergio, G:Vars are local to the single "gauge" in which they are used and do not communicate between any VC XML and 2d XML gauges.

As far as "&gt;" versus ">" in the context of updating a command or a variable, there is no difference whatsoever.
 
Hi Mr. Leaming

I already learned that about GVars... however I am afraid that I will not be able to transform what they do using LVars. I asume, that this can be achieved (and by all means, no with my very narrow XML scripting abilities).

In any event, thank very much.
All the best,
Sergio.
 
Looking at Don's original gauge, the G: vars seem to control the self test page which pops up when the gauge is initially powered on. The timer function itself is, however, a bit awkward.


A quick and simple fix to enable "communication" between the 3D button and 2D gauge would be editing GTX330.xml and replacing all instances of G: vars with L: vars, e.g. "(G:Var1)" with "(L:GTX330 Var1, number)" and "(>G:Var1)" with "(>L:GTX330 Var1, number)" and then doing the same in your 3D clickspots.
 
Last edited:
Looking at Don's original gauge, the G: vars seem to control the self test page which pops up when the gauge is initially powered on. The timer function itself is, however, a bit awkward.

Indeed! In any event, I will leave this behind for now.

Björn, thank you.

Cheers,
Sergio.
 
Try converting the G: vars into L: vars. It might just fix your problem.
 
Try converting the G: vars into L: vars. It might just fix your problem.

Mmmm... would you mind to elaborate? Before You and Mr. Leaming suggest it to me, I did it swaping all Gvars with Lvars (using non repeated names which already were in the gauge) and didn't worked. The 2D gauge didn't turned on; so I was unable to study the behavior of the remaining new LVars. This problem has kicked my butt! Since mid-May, I've been working my way to understand Dun's code.
 
A quick and simple fix to enable "communication" between the 3D button and 2D gauge would be editing GTX330.xml and replacing all instances of G: vars with L: vars, e.g. "(G:Var1)" with "(L:GTX330 Var1, number)" and "(>G:Var1)" with "(>L:GTX330 Var1, number)" and then doing the same in your 3D clickspots.

If I can recall, I did it using 'enum' as units; I will try unsing 'number' instead. Perhaps I mistyped something; let's see what happens. Thank you.
 
BJÖRN!!! YOU ARE THE MAN!!! IT WORKED!!! :wizard::wizard::wizard::wizard::wizard::wizard::wizard:

I changed:

G:Var1 to L:GTX330_Var1, number
G:Var2 to L:GTX330_Var2, number
G:Var3 to L:GTX330_Var3, number
G:Var4 to L:GTX330_Var4, number
G:Var5 to L:GTX330_Var5, number
G:Var6 to L:GTX330_Var6, number
G:Var7 to L:GTX330_Var7, number
G:Var8 to L:GTX330_Var8, number
G:Var9 to L:GTX330_Var9, number


Thank you :D:D:D:D:D:D:D
 
Back
Top