Simplify Code
Hi all masters, i need some help here. I need simplify code script from my script, its work fine but i think it can be simplified.
try destroyDialog Rtest catch()
rollout Rtest "Test-Rollout"
(
button bt1 "Load_Material"
button bt2 "Apply"
edittext 'Fdir' "" width:130 height:20 enabled:false
on bt1 pressed do
(
local curpath = Fdir.text
local newPath = getSavePath initialDir:(curpath) caption:"Select the path where your Images are located"
if newPath != undefined then
(
Fdir.enabled = true
Fdir.text = newpath
--HERE START A LARGE CODE--
meditMaterials[1] = Multimaterial ()--Apply MultiMaterial in the first slot of Material Editor
meditMaterials[1].materialList[1].diffuseMap = Bitmaptexture fileName: (Fdir.text +"\1.png") -- Load image in diffuse slot map
meditMaterials[1].materialList[1].opacityMap = Bitmaptexture fileName: (Fdir.text +"\1.png") --Load the same image in opacity slot map
meditMaterials[1].materialList[1].opacityMap.monoOutput = 1 -- Active alpha ouput for mask diffuse map
meditMaterials[1].materialList[1].showInViewport = on --Show material in viewport
--- HERE MY QUESTION,: I HAVE TO REPEAT THIS STEP FOR ALL MATERIALS ?, SOME SUGGESTION TO SIMPLIFY THIS?--
meditMaterials[1].materialList[2].diffuseMap = Bitmaptexture fileName: (Fdir.text +"\2.jpg")
meditMaterials[1].materialList[3].diffuseMap = Bitmaptexture fileName: (Fdir.text +"\3.jpg")
)
)
on bt2 pressed do
for obj in selection do if obj.material == undefined then
(
obj.material = meditMaterials[1] -- Apply Material in selection objects
)
else
(
messagebox "Ready Material"
)
)
createDialog Rtest
thanks for your help.
Comments
...
bga