ScriptSpot

Forum topic · General Scripting

Script problem

By lunar1369 · 2009-05-28

Description

A simple script to rattle through the material editor and copy the diffuse map to the bump map. Script with errors below. Any help would be appreciated.

for i = 1 to 24 do (
for t = 1 to meditMaterials[i].materialList.count do (
meditMaterials[i].materialList[t].bumpMap = meditMaterials[i].materialList[t].diffuseMap
)
)
-- Syntax error: at ), expected
-- In line: )

Comments (3)

real08121985 · 2009-05-29

Cause the listener interprets your code each time you hit return.


-- So this works:

for i=1 to 3 do ( print i )

-- But this not:

for i=1 to 3 do (
	do print i
)

real08121985 · 2009-05-29

Your code works for me, I only added a check if the material is a multimaterial.


for i = 1 to 24 do (
	local MultiMatCount = undefined
	try MultiMatCount = meditMaterials[i].materialList.count catch()
	if MultiMatCount != undefined do (
		for t = 1 to MultiMatCount do (
			meditMaterials[i].materialList[t].bumpMap = meditMaterials[i].materialList[t].diffuseMap
		)
	)
)

Note that you should send your code within code-tags for better formatting (look at the lower end of http://scriptspot.com/filter/tips).

lunar1369 · 2009-05-29

Yoodaman! How come it throws errors in the listner but not when you run the script through "Run Script"?