P3Dv4 Material Scripting

n4gix

Resource contributor
That is correct. In this example, I'm "creating" a new control variable for the left landing light:
XML:
  <PartInfo>
    <Name>ATR_light_landing_left_ON</Name>
    <Visibility>
      <Parameter>
        <Code>
          (A:ELECTRICAL MASTER BATTERY,bool)
          (L:LAND_L, number) and
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
Here is the animation and mouse control script:
XML:
  <PartInfo>
    <Name>ATR_LAND_L</Name>
    <AnimLength>10</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:LAND_L, number) 10 *</Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>HAND</Cursor>
      <MouseFlags>LeftSingle</MouseFlags>
      <CallbackCode>0x110B3 (&gt;L:LVEVENT, number)</CallbackCode>
    </MouseRect>
  </PartInfo>
Notice that the mouse control is being sent to a C++ logic controller as a hex number sent via another L:var (>L:LEVENT,number) to an event handler, which in turn controls the value of (L:LAND_L, number)

While I could control the local (L:LAND_L, number) variable directly in the <MouseRect>, doing it this way is a positive check that the actual logic controller is working properly. So, if you click on a switch and nothing happens... that means your logic controller isn't working properly! :eek:

Now what I cannot tell you is whether this applies to a Lua script at all is something else. I've not yet dived into the PDK or Lua at all...
 
i found that combining simconnect, PDK, LUA, and VARS can make great addons

thank you for the explanation, i'll check it out :)
 

Christian Bahr

Resource contributor
Hi!

Maybe someone has already dealt with the topic and can help here :)

It's about the taillights of a car that are presented via PBR textures. When it gets dark, the Night Texture is automatically turned on (AdditiveNightOnly). That was the old standard procedure for objects in the FSX:

p3dv4_porsche_lua_script_taillights.jpg



My goal is that the Night Map is not automatically switched on, but by the Nav Lights Switch. The developers of the P3Dv4 have provided the LUA material scripting for such things and I would like to use this elegant option -> LUA Material Script.

Does anyone know how to approach this idea?
 

Christian Bahr

Resource contributor
My question has already been settled. :)
The answer was given by Manfred Jahn : Did this test with an aircraft model ...

For this enormous knowledge fund I love this forum :)

...

In a slightly modified form, the LUA script looks like this:

Code:
!lua
if varget("A:LIGHT STATES", "Mask") & 0x0004 > 0 then
  varset("T:EmissiveTexture", "string", "porsche_carrera_gt_emissive.dds")
  varset("T:EmissiveScale", "number", 1.00)
else
  varset("T:EmissiveTexture", "string", "")
end
This script turns on the Night Map of the taillights with the Landing Lights switch:

porsche_lua_script.jpg

The dynamic lights (headlights and taillights) as well as the Night Map are switched on via the Landing Lights Switch
 
Top