ZBrushCentral

Question: Calling a routine using a variable name to choose the routine?

Hey guys I’m trying to get something working. I’m not sure if zscript supports structure like this. but I want I want to use a routine to call another routine using a variable.

The idea is that I have 2 routines. One where it will prepare my loop to go. And will have some extra checks later on. for visibility and folder stuff.

I don’t want to copy paste these conditions all the time. So I want to have one routine to check if the actions should be executed(actions being the second routine. PolypaintEnable or Test)

[IButton, "PolyPaint","enable polypaint",
	
	[RoutineCall, RoutineCaller,  "PolypaintEnable"]

]

[IButton, "Test","Test for testing",
	
	[RoutineCall, RoutineCaller,  "Test"]

]

[RoutineDef, RoutineCaller,

	[RoutineCall, Prep] 

	[loop, [SubToolGetCount],

		[RoutineCall, [VarLoad, routineToCall]]  //problem here routinecall won't accept variable
		[RoutineCall, NextSubtool]

	]

	[RoutineCall, LastSubtool]
,
routineToCall
]


[RoutineDef, PolypaintEnable,

	[IPress,Tool:Polypaint:colorize]	

]

[RoutineDef, Test,

	[Note, "TestNote"]	

]

Now in my mind this should work fine. But | [RoutineCall, [VarLoad, routineToCall]] | Is not accepting a varload. Is there any work around for this to still work?
code

hi @sunray_muijsson_f ,

did you try to check what the varload returns with [Note] ? because it just return an Integer value.
If you want to use [Varload] then you must first [VarSave] on disk, so you can reload the variables list.
a Routine Name is just a string value, so once you have it properly referenced and value are assigned, it should be just fine.

Hope it helps,
Nicolas

1 Like

Ah I see. makes sense thanks for the fast reply!! Got it working now :slight_smile: