P3Dv4 Material Scripting


Resource contributor
That is correct. In this example, I'm "creating" a new control variable for the left landing light:
          (L:LAND_L, number) and
Here is the animation and mouse control script:
        <Code>(L:LAND_L, number) 10 *</Code>
      <CallbackCode>0x110B3 (&gt;L:LVEVENT, number)</CallbackCode>
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

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:


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:

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


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