P3D v4 material scripting

Hello
i wanted to make a script for my object to appear only when it rains ( my objects has pbr materials )
i made a box and assigned a scrpit to it
i tested : it doesn't work
i tried if else things editiing .................. a bunch of things but couldsn't get it right
here is my script hope you help me :)
thnx in advacne :)

!lua

local raining = 0x00000004
local snowing = 0x00000008

local precipState = varget("A:AMBIENT PRECIP STATE", "Mask")
precipState = math.floor(precipState)

local colorRed = 1.0
local colorGreen = 1.0
local colorBlue = 1.0
local colorAlpha = 1.0
local colorAlphaN = 0.0

varset("T:AlbedoTexture", "string", "")

if precipState == raining then


varset("T:AlbedoAlpha", "Number", colorAlpha)
varset("T:AlbedorRed","Number",colorRed)
varset("T:AlbedoGreen","Number",colorGreen)
varset("T:AlbedorBlue","Number",colorBlue)

else
varset("T:AlbedoAlpha", "Number", colorAlphaN)
varset("T:AlbedorRed","Number",colorRed)
varset("T:AlbedoGreen","Number",colorGreen)
varset("T:AlbedorBlue","Number",colorBlue)


end

if precipState == snowing then


varset("T:AlbedoAlpha", "Number", colorAlpha)
varset("T:AlbedorRed","Number",colorRed)
varset("T:AlbedoGreen","Number",colorGreen)
varset("T:AlbedorBlue","Number",colorBlue)

else
varset("T:AlbedoAlpha", "Number", colorAlphaN)
varset("T:AlbedorRed","Number",colorRed)
varset("T:AlbedoGreen","Number",colorGreen)
varset("T:AlbedorBlue","Number",colorBlue)



end
 
@Lagaffe thnx for that link
i tested it in the SIM and here is what i got :(
the right one is the plane in the zip file that works fine
the left is the same MDL but scenery object can't load scrpit
so i opened MCX and found this ( 2nd photo ) i mean with both P3D v4 and v4.4 export
the scrpit attribute isn't exported in the BGL lib
and the script attribute is present before the export ( 3rd photo )
so the BGL comp is deleting that value from the mdl when converting to BGL :(
 

Attachments

no i want to make my own objects
for jetways and papis i use sode but for my water
bus
cars
trucks
and scripted objects
i like to make my own engine so i can debug it
and i did that in 20 min by spawning an A320 in a runway and it works
all i need now is to continu the developing and build my new sceneries :)

maybe i'll share it for developers who want some advanced objects but still a WIP
i'll work on it tomorrow
 
Hi. You have found a solution? Im trying to script a ground poly texture exported from 3dsmax and mcx and the error reporting in prepar3d does not recognize anything. It shows something like this. Do you know if its supported for ground polys in mcx?


"error=Gauge/Script Error
Type: Unknown
Name: Unknown
Error: Invalid script (command not found - perhaps a space is missing or there's an extra space?): "" in: 
!lua

local raining = 0x00000004

local precipState = varget(“A:AMBIENT PRECIP STATE", "Mask")
precipState = math.floor(precipState) "
 

Attachments

Last edited:
Hello @DaveWG
i tried to use TExtureOffsetU / V but it doesn't work :|
if i try to set the deffuse texture to null it works (i get a white texture) but if i change to UV rotation or offset it doesn't change
any thoughts ?
 
Top