ScriptSpot

Forum topic · General Scripting

Affect Array index via Slider?

By Vapourise · 2012-04-17

Description

Hi there, say I have an array of objects and I want to use a slider to alternate between those objects how would I go about doing this?

I theory I understand that every point on the slider would relate to an index in the array, then the action for every point on the slider would trigger the code to affect that indexed object

i.e. slider position 1 = array index 1
slider action 1 = code to affect array index 1

Any help would be greatly appreciated :)

K

Comments (1)

Maybe like this:

miauu · 2012-04-17


(
	global rol_sliderTest
	try(destroyDialog rol_sliderTest)catch()
	rollout rol_sliderTest ""
	(
		local obj = undefined
		slider sld_01 ""  range:[0,10,0] type:#integer ticks:10
		
		on rol_sliderTest open do
		(
			obj = objects as array
			sld_01.range = [0,obj.count,0]
		)
		
		on sld_01 changed val do
		(
			if val != 0 do
			(
				print obj[val].name
				obj[val].wirecolor = [(random 0 255),(random 0 255),(random 0 255)]
			)
		)
	)
	createdialog rol_sliderTest 	
)