P3D v4 V4 Part Code (ModelDef) for Buttons; Question

#1
Hey all,

I am trying to transfer mouserect code from a 2D FS2004 XML Gauge to the modeled solid Polygon mesh buttons in the VC. I am having an issue. Do you see what I might be doing wrong?

The original gauge is written in FS9 XML. The ModelDef list is of course in FSX / P3D XML. Transferring the code over isnt working well...


Actual gauge in FS2004 Schema, button (Mouserect, etc)

Code:
<Area Left="71" Top="107" Width="36" Height="26">
<Tooltip>(1)</Tooltip>
<Cursor Type="Hand"/>
<Click Kind="LeftSingle">(L:GTX327_ON,bool)
if{
(M:Event) 'LeftSingle' scmp 0 ==
if{ @SetDigit(1) }
}
</Click>
</Area>

3D Polygon Mesh Button Code from the ModelDef list;
Code:
    <PartInfo>
        <Name>CH70_avs_GTX327_N1</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:CH70_avs_GTX327_N1, bool) 100 *</Code>
                <Lag>200</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <MouseFlags>LeftSingle</MouseFlags>
                 <CallbackCode>
                                           (L:GTX327_ON,bool)
                                                if{
                                                    (M:Event) 'LeftSingle' scmp 0 ==
                                                            if{ @SetDigit(1) }
                                                   }
                 </CallbackCode>
            <TooltipText>1</TooltipText>
        </MouseRect>
    </PartInfo>

This is the part that is the issue; working FS9 code in the 2D gauge:

<Click Kind="LeftSingle">(L:GTX327_ON,bool)
if{

(M:Event) 'LeftSingle' scmp 0 ==
if{ @SetDigit(1) }
}
</Click>

FSX ModelDef;

<CallbackCode>
(M:Event) 'LeftSingle' scmp 0 ==
(L:GTX327_ON,bool) if{ <<<-- THIS PART IS WRITTEN ABOVE M:EVENT IN FS9 SCHEMA
if{ @SetDigit(1) } <<<-- THIS PART IS BELOW M:EVENT IN FS9 SCHEMA
}
</CallbackCode>

I have experimented with about 3 versions of layouts. None seem to work. Any clues? I tried writing it without the (L:GTX327_ON,bool) if{ section and that did nothing, so I figured it requires this section to actuate the code it triggers. Or perhaps I just have things out of place and there is a way to write it that I havent thought of yet?
 
#2
Bill, you can't use a macro in modeldef (AFAIK!), so you'll have to include its code explicitly. Otherwise the two if brackets can be left as in the original FS9 script.
 
#4
Ok... I have been trying to do this myself and its just above my abilities.

This is the Macro code(s) for this button entry. Basically, this is the buttons for entering your Transponder codes, 1 thru 0, or 0 thru 9. How on Earth might would one write a code script for each button from this exotic, ultra sophisticated Macro code?


Code:
<Macro Name="SetDigit">(L:SetCode, enum) 0 ==
if{ (L:XPNDR_CODE 1000,number) (&gt;L:TRANSPONDER2 CODE 1000,number) (L:XPNDR_CODE 100,number) (&gt;L:TRANSPONDER2 CODE 100,number) (L:XPNDR_CODE 10,number) (&gt;L:TRANSPONDER2 CODE 10,number) (L:XPNDR_CODE 1,number) (&gt;L:TRANSPONDER2 CODE 1,number) 1 (&gt;L:SetCode,enum) @1 (&gt;L:TRANSPONDER2 CODE 1000,number) 2 (&gt;L:CursorPos,enum) }
els{ (L:SetCode, enum) 1 ==
if{ 2 (&gt;L:SetCode,enum) @1 (&gt;L:TRANSPONDER2 CODE 100,number) 3 (&gt;L:CursorPos,enum) }
els{ (L:SetCode, enum) 2 ==
if{ 3 (&gt;L:SetCode,enum) @1 (&gt;L:TRANSPONDER2 CODE 10,number) 4 (&gt;L:CursorPos,enum) }
els{ (L:SetCode, enum) 3 ==
if{ 4 (&gt;L:SetCode,enum) @1 (&gt;L:TRANSPONDER2 CODE 1,number) 0 (&gt;L:CursorPos,enum)
(L:TRANSPONDER2 CODE 1,number) (L:TRANSPONDER2 CODE 10,number) 16 * + (L:TRANSPONDER2 CODE 100,number) 256 * + (L:TRANSPONDER2 CODE 1000,number) 4096 * + (&gt;K:XPNDR_SET) 0 (&gt;L:SetCode,enum) }
els{ (L:SetCode, enum) 5 ==
if{ 1 (&gt;L:SetCode,enum) @1 (&gt;L:TRANSPONDER2 CODE 1000,number) 2 (&gt;L:CursorPos,enum) }
}
}
}
}
</Macro>
It would be doable for me to figure out if it didnt rely on digits added to the equasion, such as (2) (4), etc...

Code key in Macro; @SetDigit(1) (thru 9 or zero)


What in the world is 256 *, 4096 *, 16 * ? I am totally lost... :(
 
#6
Thanks JB3DG,

I think I will be going with a different gauge on this one. Just wondering if there is a easier way to tap in code into the system. I wonder if there is a XML Transponder that was stock gauges for FSX or FS2004 where one could see how a basic transponder code is written?
 
Top