ScriptOP: Appending and Accessing other operators

Hello!

I haven’t touched sciptOPs in a minute, and I keep blocking on this seemingly simple concept. I am trying to create custom parameters holding the references to a few different OPs, which seem to work. However, I can’t figure out how to assign/ change the value of these custom parameters, weather its an int, Pulse, or DAT… What am I doing wrong?

def onSetupParameters(scriptOp):
	variablePage = scriptOp.appendCustomPage('Custom')

	timerReset = variablePage.appendPulse('Resettimer', label='Reset Timer')
	timerReset.val = op('basicControls')['reset']
	
	currentTimer = variablePage.appendInt('Timer', label='Current Timer')
	currentTimer.val = 0
	
	animSequences = variablePage.appendDAT('Animtable')
	animSequences.val = op('Animtable')

	return

def onCook(scriptOp):
	
	animTable = op(scriptOp.par.Animtable.val)
	print(scriptOp.par.Resettimer.val)
	
	# if the Timer value is 0, the program has not started. Press '9'.
	if scriptOp.par.Timer.val == 0 & scriptOp.par.Resettimer.val == 1:
		nextMoveIndex = random.randint(1, animTable.numRows - 1)
		scriptOp.par.Timer.val = animTable[nextMoveIndex, 1]
		print(nextMoveIndex)
		print(scriptOp.par.Timer.val)
	return

Sequencer.2.toe (6.2 KB)

Please help me understand!
Thanks you!!

Hi @hd.maxi,

this might be a bit misconception on how the Script Operators would work. Self referential parameter setting to imitate counting is difficult.

I would recommend looking at the Timer CHOP for this.

Otherwise looking at your script an issue could be that your if expression is checking on the value of a Pulse parameter which will evaluate to 0 always. You could switch this to a Momentary parameter to be able to catch it in the cook loop.

Hope this helps
Markus

Hey snaut! thank you for your reply.

I ended up going with the loop_frame channel of an info chop to determine when the sequencer should select another video to play (my goal being to display a series of sequences that each has a different number of frames).

I still have a bunch of questions about script operators, but for now it works!