[Closed] where is wrong in this code?
Hi guys…
sometimes i have a alpha channel in frist material, then i write the script , i want the script to do some check if there is a alpha channle or no …(map in Opcity…”
if there is a alpha channel, It will pick the texturemap not only in “diffuse color”,but also in the “Opacity…” it mean it’s the same , but it not work now…
OK thank you Pjanssen…with your help i have solved my problem
This part seems a bit odd to me:
local d0_found = off
for f in files while not (d0_found) do
(
file = getfilenamefile f
case of
(
(not d0_found and matchpattern file pattern:"*_d0"):
if meditmaterial[1].diffuseMap.bitmap.hasAlpha then
meditMaterials[1].opacityMap= bitmaptexture filename:f
append maps f
d0_found = on
else
)
)
The “case of” statement is a bit redundant here, you can just as well replace it with an “if”.
Additionally, I’m not sure if this is causing the problem, but just to make sure: wrap the code after “hasAlpha then” in parentheses. It could be that only the first line after the if statement is evaluated if you write it like this.
Oh and the else is a little redundant too.
for f in files do
(
file = getfilenamefile f
if (not d0_found and matchpattern file pattern:"*_d0")
(
if meditmaterial[1].diffuseMap.bitmap.hasAlpha do
(
meditMaterials[1].opacityMap = bitmaptexture filename:f
append maps f
exit --this stops the loop, so there's no need to keep the d0_found variable around.
)
)
)