1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FSX <CallbackCode> bug

Discussion in 'Gauges' started by Vylsain, 4/5/12.

  1. Vylsain

    Vylsain

    Joined:
    11/1/12
    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: 10/5/12
  2. n4gix

    n4gix Resource contributor

    Joined:
    26/9/06
    Messages:
    9,524
    Country:
    unitedstates
    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>
    
  3. taguilo

    taguilo Resource contributor

    Joined:
    20/10/06
    Messages:
    1,068
    Country:
    argentina
    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
  4. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    Ok thanks, I'll check this on Wednesday.

    n4gix : thx for the tip :)
  5. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    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.

    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: 9/5/12
  6. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    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: 9/5/12
  7. n4gix

    n4gix Resource contributor

    Joined:
    26/9/06
    Messages:
    9,524
    Country:
    unitedstates
    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).
  8. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    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: 10/5/12
  9. n4gix

    n4gix Resource contributor

    Joined:
    26/9/06
    Messages:
    9,524
    Country:
    unitedstates
    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 }
  10. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    Ok I'll try this tomorrow.

    Thank you ! :)
  11. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    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 ?
  12. tgibson

    tgibson

    Joined:
    22/9/06
    Messages:
    4,710
    Country:
    us-california
    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,
  13. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    Ok I'll search for these gauges.

    Thanks :)
  14. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    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 !
  15. Naruto-kun

    Naruto-kun

    Joined:
    24/6/10
    Messages:
    625
    Country:
    southafrica
    The joys of FSX programming where you so easily put the wrong letter or miss a bracket or in C++, a break. :D

Share This Page