You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
"""
|
|
Script DAT Callbacks
|
|
me - this DAT
|
|
scriptOp - the OP which is cooking
|
|
"""
|
|
|
|
def onSetupParameters(scriptOp: scriptDAT):
|
|
"""
|
|
Called to setup custom parameters for the Script DAT.
|
|
"""
|
|
page = scriptOp.appendCustomPage('Custom')
|
|
page.appendFloat('Valuea', label='Value A')
|
|
page.appendFloat('Valueb', label='Value B')
|
|
return
|
|
|
|
def onPulse(par: Par):
|
|
"""
|
|
Called when a custom pulse parameter is pushed.
|
|
"""
|
|
return
|
|
|
|
def onCook(scriptOp: scriptDAT):
|
|
"""
|
|
Called when the Script DAT needs to cook.
|
|
"""
|
|
scriptOp.clear()
|
|
|
|
# Safely get the selection ID from the operator 'SelectId'
|
|
# We convert to int immediately to use in the loop comparison
|
|
target_op = op('SelectId')
|
|
select_id=target_op['id']
|
|
# try:
|
|
# select_id = int(target_op['id', 0].val) if target_op else -1
|
|
# except (ValueError, TypeError, AttributeError):
|
|
# select_id = -1
|
|
|
|
# Check if there is an input connected to the Script DAT
|
|
if len(scriptOp.inputs) > 0:
|
|
input_dat = scriptOp.inputs[0]
|
|
|
|
for i in range(input_dat.numRows):
|
|
# Access the string value of the cell in the second column (index 1)
|
|
raw_text = input_dat[i, 1].val
|
|
trimmed_text = raw_text.replace(" ", "")
|
|
|
|
# If this row matches our selection ID (offset by 1 as per original logic)
|
|
if i == select_id + 1 and select_id!= -1:
|
|
display_text = f"({trimmed_text})"
|
|
else:
|
|
display_text = trimmed_text
|
|
|
|
scriptOp.appendRow([input_dat[i, 0].val, display_text, select_id])
|
|
|
|
return
|
|
|
|
def onGetCookLevel(scriptOp: scriptDAT):
|
|
"""
|
|
CookLevel.AUTOMATIC - inputs changed and output being used.
|
|
CookLevel.ON_CHANGE - inputs changed, output used or not.
|
|
CookLevel.WHEN_USED - every frame when output is being used
|
|
CookLevel.ALWAYS - every frame
|
|
"""
|
|
return CookLevel.AUTOMATIC |