Material Scripting Metallic Texture

Hi,

I have created two different metallic textures for my AlbedoTexture. The one is called asphapbr.dds (for dry weather) and the second is called asphapbr_RA.dds (for wet weather)
I 'm trying to crate a script so that the sim would read the first one when it does not rain and the other one when it rains whilst the AlbedoTexture remains the same.
Here is the script I use. Of course, it does not work and I'm trying to find out how and if I can make it work.

!lua
--Get precip state.
local raining = 0x00000004
local precipState = varget("A:AMBIENT PRECIP STATE", "Mask")
precipState = math.floor(precipState)
local StringOld = varget("T:MetallicTexture", "String")
local StringNew

if precipState == raining then
StringNew=string.sub(StringOld,1,8) .. "_RA.DDS"
else
StringNew=string.sub(StringOld,1,8) .. ".DDS"
end

varset("T:MetallicTexture","String",StringNew)


I do not even know if a script could work to change the metallic texture for the same Albedo one.

Can anybody help?

-=Manwlo=-
 
Top