P3Dv4 Material Scripting

#1
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
 
#3
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
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#5
With MCX you can also add a material script to a MDL file.
 
#6
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
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#7
In the material attributes you'll find the script name. That's all that's stored in the MDL.
 
#8
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?
 
#12
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:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#13
You are sure you are using the v4 SDK and exporting as v4 MDL?

Just tried it here and it is working fine.
 
#15
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?
 
#16
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:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#17
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.
 
#19
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?
 
#20
@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:
Top