ScriptSpot

Forum topic · General Scripting

Variable = Variable

By kimarotta · 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)

This should work:

Garp · 2012-07-05

[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

kimarotta · 2012-07-05

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...

barigazy · 2012-07-05

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

kimarotta · 2012-07-05

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...