Little maxscript questions

Hey everybody.

I am working on my first application in maxscript. I hope you dont mind I will use this thread to ask little (probably stupid) questions.

First one :

For some reason he is only outputting “Diffuse Updated” while he also has to print the other also. But the ignores the other folowing if statements. I guess its a stupid mistake but I can’t find it.


if (matchPattern imgFileName_Part3 pattern:"1*" ) then
						(	
							if( matchPattern imgFileName_Part2 pattern:"D1*") then
(
print "Diffuse Updated"------------------------------------------
)
							
if( matchPattern imgFileName_Part2 pattern:"N1*") then
(
print "Normal Updated"------------------------------------------
)
							
if( matchPattern imgFileName_Part2 pattern:"S1*") then
(
print "Specular Updated"------------------------------------------
)
							
if( matchPattern imgFileName_Part2 pattern:"O1*") then
(
print "Opacity Updated"------------------------------------------
)	
print "blabla"
)
else
(
btn_File.text = "Wrong File"
)
)

It would helpful to know some test values you are using for imgFilename_Part2. In the script snippet you’ve posted, the matchPattern can only be true for one of the if-statements. It sounds as if you may be expecting some other result, but I can’t be certain.

the total filename is psdname_D1N1S1O1_1.tga
so imgFileName_Part2 = D1N1S1O1

filename = texmap.filename
		parts = filterString filename "\\"
		local imgFileName =filterString parts[parts.count] "_"
		
		if (imgFileName.count == 3) then
		(
			imgFileName_Part1 = imgFileName[1]
			imgFileName_Part2 = imgFileName[2]
			imgFileName_Part3 = imgFileName[3]
                )

I just want to check if the d1 and other little strings are in that string.

We’ll there you go. For example, matchPattern imgFileName_Part2 “N1*” will only match the string if it begins with N1. matchPattern imgFileName_Part2 “N1

matchPattern imgFileName_Part2 pattern:"??N1*" would also work.

The * wildcard stands in for any number of characters in part of a string. The ? wildcard stands in for a single character in a string.

I hope that helps.

it sounds like you may want to use findstring instead of matchpattern.

ie: if ((findstring filename “d1”) != undefined) then

reads as “if the variable filename contains the substring “d1” then…”

findString returns either the index of the search string within the string, or undefined if it cannot find the search string. IIRC matchpattern is faster, but it doesn’t sound like that’s a big concern… findstring was just always easier for me to grok.

Ok Thank you. Problem solved, hehe

An other question.
I used the macrorecorder to get this code.

meditMaterials[2].bumpMapEnable = on
meditMaterials[2].bumpMap = Normal_Bump ()
meditMaterials[2][#Maps][#Bump__Map__1____Normal_Bump].normal_map = Bitmaptexture fileName:".\sceneassets\images\psdname_N.tga"
meditMaterials[2][#Maps][#Bump__Map__1____Normal_Bump].normal_map.alphaSource = 2

But I am still getting the error : unkown property
But I just copied the code and modified it like the other code I used. What am I doing wrong?

EDIT: Solved it

(srry for double post)

How can I edit the filename from a tga that I have loaded thanks to a mapbutton from my rollout ?

Edit:

nvm, got an answer

other question.

How can I load an psd with a mapbutton? it does nto work with psd :s