ScriptSpot home

Forum topic · General Scripting

Variable = Variable

By Willian Kim · 2012-07-05

Description

Hi,

someone could help me with this?

I have the variable that equal a string with the otrher variables...

for exemple:


slot = 1
base = meditMaterials[slot].materialList[a].texmap_diffuse
	
    for a = 1 to 5 do (
           base = Color_Correction map:( base)
		base.rewireR = 0
		base.rewireG = 1
		base.rewireB = 2
		base.rewireA = 3
     )

I want to be like this...


slot = 1
	
    for a = 1 to 5 do (
           meditMaterials[slot].materialList[a].texmap_diffuse = Color_Correction map:( meditMaterials[slot].materialList[a].texmap_diffuse)
		meditMaterials[slot].materialList[a].texmap_diffuse.rewireR = 0
		meditMaterials[slot].materialList[a].texmap_diffuse.rewireG = 1
		meditMaterials[slot].materialList[a].texmap_diffuse.rewireB = 2
		meditMaterials[slot].materialList[a].texmap_diffuse.rewireA = 3
     )

But "base" not print meditMaterials[slot].materialList[a].texmap_diffuse, but yes the result this...

Thanks in advanced...

Comments (4)
Garp

This should work:

[code]
slot = 1
base = mEditMaterials[slot]

for mtl in base do
mtl.texmap.diffuse = color_correction map:(mtl.texmap_diffuse) \
rewireR:0 rewireG:1 rewireB:2 rewireA:4

Reply to Garp
Willian Kim

Yeah man is very good, this loop is very much more functionally... but yet have the question...

Is possible define the variable with string with variable ?

for exemple?

base = meditmaterials[slot] != base = meditmaterials[slot]

I would like use a exemple: "base.texmap.diffuse" but " base = #Multi/Sub-Object:01 - Default" and not "base = meditmaterials[slot]"

understand?

Thanks very much...

Reply to Willian Kim
Branko Živković

I TRY TO UNDERSTAND BUT ...
make a sceenshoot to see your problem

Reply to Branko Živković
Willian Kim

Hey ... I tried to summarize the problem...

I tried define the variable...


base = meditMaterials[slot].materialList[a].texmap_diffuse
-- Type error: array index must be positive number, got: , got: undefined

but "slot" and "a" is a variable... How do ? Understand ?

thanks in advance...