LNXSDK/leenkx/blender/lnx/logicnode/logic/LN_select_output.py

41 lines
1.3 KiB
Python
Raw Normal View History

2025-01-22 16:18:30 +01:00
from lnx.logicnode.lnx_nodes import *
class SelectOutputNode(LnxLogicTreeNode):
"""Selects one of multiple outputs depending on the index.
@input In: Action input.
@input Index: Output index to run.
@output Default: Run if output index not present.
"""
bl_idname = 'LNSelectOutputNode'
bl_label = 'Select output'
lnx_version = 1
min_outputs = 2
def __init__(self):
super(SelectOutputNode, self).__init__()
array_nodes[self.get_id_str()] = self
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxIntSocket', 'Index')
self.add_output('LnxNodeSocketAction', 'Default')
self.add_output('LnxNodeSocketAction', 'Index 0')
def draw_buttons(self, context, layout):
row = layout.row(align=True)
op = row.operator('lnx.node_add_output', text='New', icon='PLUS', emboss=True)
op.node_index = self.get_id_str()
op.socket_type = 'LnxNodeSocketAction'
op.name_format = 'Index {0}'
op.index_name_offset = -1
column = row.column(align=True)
op = column.operator('lnx.node_remove_output', text='', icon='X', emboss=True)
op.node_index = self.get_id_str()
if len(self.outputs) == self.min_outputs:
column.enabled = False