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

FSX <CallbackCode> bug

Messages
51
Country
france
[Solved] <CallbackCode> bug

Hello everyone.

I have a really strange bug in my MouseRect.

I wrote this code :

Code:
        <PartInfo>
        <Name>sna_prep</Name>
        <AnimLength>10</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:PrepPos, bool) 5 *</Code>
	        <Lag>50</Lag>
            </Parameter>   
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
	    <TooltipText>Selection du but de preparation</TooltipText>			
	    <MouseFlags>LeftSingle+LeftRelease</MouseFlags>
            <CallbackCode>
            </CallbackCode>
        </MouseRect>
    </PartInfo>

It was working perfectly !

Ok, so I keep going and I write the code inside the CallbackCode :

Code:
(M:Event) 'LeftSingle' scmp 0 == 
	if{ 1 (>L:PrepPos, bool) }				
(M:Event) 'LeftRelease' scmp 0 == 
	if{ 0 (>L:PrepPos, bool) }

Dammit, the cursor disappears... Then I delete this part of the code and come back to the working one.

But, it's still doesn't work...:confused:
The code is exactly the same than before but it doesn't work anymore.:rolleyes:

The funny part is that I have a dozen of such "sna_...", all identical and those I didn't modify still work.

So I have this one not working :

Code:
<PartInfo>
        <Name>sna_dest</Name>
        <AnimLength>10</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:DestPos, bool) 5 *</Code>
				<Lag>50</Lag>
            </Parameter>   
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
			<TooltipText>Selection du but de destination</TooltipText>
			<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
            <CallbackCode>
            </CallbackCode>
        </MouseRect>
    </PartInfo>

and this one working perfectly :

Code:
<PartInfo>
        <Name>sna_bad</Name>
        <AnimLength>10</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:BadPos, bool) 5 *</Code>
				<Lag>50</Lag>
            </Parameter>   
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
			<TooltipText>But ADditionnel</TooltipText>
			<MouseFlags>LeftSingle+LeftRelease</MouseFlags>
            <CallbackCode>
            </CallbackCode>
        </MouseRect>
    </PartInfo>

It's exactly the same code with only the variable's name changing. I tried some XForm in GMax to check the clickable zone, tried to redo the animation and Mouserect procedures in GMax but no result...

I really don't understand how 2 identical codes are leading me to 2 different results... :(

Do you have an idea ?

Thanks :)

Edit : ": D" are replaced with :D in the code but I did not put any smileys in my XML code ^^
 
Last edited:
Odd, that! I see nothing at all wrong with your XML script...

By the way, when posting XML or C code, use the # icon of the editor to wrap your snippet of script/code with the
Code:
 tags!

[CODE]
  <PartInfo>
    <Name>sna_prep</Name>
    <AnimLength>10</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:PrepPos, bool) 5 *</Code>
        <Lag>50</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Selection du but de preparation</TooltipText>
      <MouseFlags>LeftSingle+LeftRelease</MouseFlags>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 ==
             if{ 1 (>LestPos, bool) }
        (M:Event) 'LeftRelease' scmp 0 ==
             if{ 0 (>LestPos, bool) }
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
I agree with Bill, nothing seems wrong at first sight.

I think that maybe you have an illegal character (hidden?) somewhere in the code that prevents it for being loaded into the MDL. If I were you I would make these test:

1) Check that the complete <Part> with trouble is actually stored inside the MDL , using an Hex editor.

2) If the problem exists in the Variable name, use another one on the same piece of code and see what happens.

Tom
 
I downloaded an Hex Editor and opened my mdl file but how do you know if the <Part> with trouble is stored inside the MDL ?

I found the text of the TooltipText but the rest is unreadable, made of unicode characters.

If the problem exists in the Variable name, use another one on the same piece of code and see what happens.

Even if I delete all the variables of the section and leave only the tags it doesn't work. As I said, I have 2 identical PartInfo sections, one works and not the other one...

Thanks
 
Last edited:
Update : The problem may come from GMax since that if I apply this MouseRect to another knob it works.

The 3D knob would be the problem ? I tried to redo the AttachPointTool process, tried to apply an XForm but nothing works... :(

Edit : I tried with a 3rd button :
- it was working, showing the cursor and the text
- I wrote the XML code : working ok
- I make the link with the AnimationManager : doesn't work anymore
 
Last edited:
Select the knob giving the problem, then open the Track View. Check the Animation/Scale entry. You must see X=100.0 Y=100.0 Z=100.0

If any one of the three are not 100.0 then you will need to add an X-Form Modifier, then Reset Scale, then collapse back to E-Poly or E-Mesh as desired.

Alternatively, build a new knob and make sure that if you need to scale it to final size that you do so only at one of the sub-levels (vertex, edges, faces, polys, element).
 
It works !! Thank you very much Bill :)

The XForm however change the scale when applied to a group of objects. Is there a way to scale a group of objects without changing their scale values or must we apply the XForm for each object and it might take a whole day ? ^^

For my 3D gauge, there's only one button that still doesn't work : do you see any error in the code ?

Code:
	<PartInfo>
        <Name>sna_rotbudbad</Name>
        <AnimLength>12</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:RotButBadPos, enum)</Code>
				<Lag>50</Lag>
            </Parameter>   
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
			<TooltipText>Selecteur de parametre</TooltipText>
			<MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
            <CallbackCode>
			(M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == ||
				if{ (L:RotButBadPos, enum) 1 + (>L:RotButBadPos, enum) }			
			(M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == ||
				if{ (L:RotButBadPos, enum) 1 - (>L:RotButBadPos, enum) }
				
			(L:RotButBadPos, enum) 13 == 
				if{ 1 (>L:RotButBadPos, enum) } 
			(L:RotButBadPos, enum) -1 == 
				if{ 11 (>L:RotButBadPos, enum) }
            </CallbackCode>
        </MouseRect>
    </PartInfo>

I have many other questions on other subjects but I'll create a new topic.
 
Last edited:
Although "logically" this should work, I've never been successful using this format:

Code:
(M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == ||
     if{ do*something }
Instead, I've always broken them up into two separate mouse events:
Code:
(M:Event) 'LeftSingle' scmp 0 == 
     if{ do*something }

(M:Event) 'WheelUp' scmp 0 == 
     if{ do*something }
 
No results :(

It's really hard to find the cause of this without any clue ! :scratchch

Is there a way to see how the variable is modified during the game ? Some kind of debugging tool ?
 
I set up a little gauge with a digital readout of the variable, or modify an existing digital gauge to temporarily display this variable instead. But there are special gauges out there to display the values of variables too.

Hope this helps,
 
Code:
<PartInfo>
       <Name>sna_rotbu[COLOR="Red"]d[/COLOR]bad</Name>
        <AnimLength>12</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:RotBu[COLOR="Lime"]t[/COLOR]BadPos, enum)</Code>
		<Lag>50</Lag>
            </Parameter>   
        </Animation>
        ...

:banghead:

So much time spent on this... :rolleyes:

Thanks for your help, I managed to make a 2D debug gauge and noticed that my variable was working pefectly. I glanced at my modeldef another time and found this mistake... :D

Thank you for your help, problem solved !
 
The joys of FSX programming where you so easily put the wrong letter or miss a bracket or in C++, a break. :D
 
Back
Top