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

P3Dv4 Material Scripting

fs1

Messages
301
Country
brazil
Is there any default BGL or MDL object that has material scripting already embedded in it?
I need one existing object to do some tests.
If there is any, can I create and attach a script to an existing MDL/BGL via MCX?
Thanks
 
The default Mooney g1000 interior mdl uses material scripting for the rain effect.
 
Thanks. When you mean interior, what part are you referring to?
I am looking around the Mooney G1000 in heavy rain but cannot spot any material changes. Thanks
 
With MCX you can also add a material script to a MDL file.
 
Thanks Arno and DaveWG. I really opened the Mooney_Bravo_Interior.mdl with MCX version 1099974, went to the Material's Editor and could not find any tabs for scripting or similar.

Arno, how can you do this? Add a little script to an existing MDL ? I have been looking at the forum bur could not find any MCX documentation. Thanks
 
In the material attributes you'll find the script name. That's all that's stored in the MDL.
 
So to add a script to an existing MDL, just open a regular MDL file and add a LUA file name to it? And then save it as a P3Dv4 MDL?
 
Where should my LUA file reside in the P3D root? Or it will be embedded in the MDL?
 
Thanks. @arno, I added the lua script file name in MCX script field.

When I export the P3Dv4 MDL, and try to load it again the script field loads empty

Also a string scan in the exported MDL does not show the script name in it.

Any clues?

Thanks
 
Last edited:
You are sure you are using the v4 SDK and exporting as v4 MDL?

Just tried it here and it is working fine.
 
EDIT: I have the SDK v4 installed with the export settings pointing to XtoMDL exe

What could it be?
 
Last edited:
I have checked the export settings pointing to XtoMDL.exe in the v4 SDK.
I export it as MDL P3D V4 MDL and the file is created. My script file is in the same directory as the import and export MDLs.
Do you need to include full path on the lua script file?
 
I just made it work. MCX only updates the script field if there is a texture associated with the material. If there is no texture, there is no update.

Is this the normal behavior?

Thanks
 
Last edited:
That was a bug in my code, some material settings got under a check if there is a texture when writing the X file. I have fixed that now, so in the next build it should work.
 
Also, I change the PrecipWindshieldEffect.lua code to:

Code:
!lua

local colorRed = 0.0
local colorGreen = 0.0
local colorBlue = 1.0

varset("T:DiffuseColorRed","Number",colorRed)
varset("T:DiffuseColorGreen","Number",colorGreen)
varset("T:DiffuseColorBlue","Number",colorBlue)

I wanted to check the material setting, but it does not work when I load the v4 Mooney G1000.

Ant clues?
 
@arno, I modified a simple MDL with MCX to include the above script file name and also nothing happens. I have the above script in a file in the root\Scripts folder.

Can't make it work. I placed the file via BGL and also dynamically and nothing. The objects shows, but no material scripting works.

See attached both files (renamed *.lua to _lua.txt so could be uploaded)

What am I doing wrong? Thanks
 

Attachments

Last edited:
Back
Top