from lnx.logicnode.lnx_nodes import * class SwitchNode(LnxLogicTreeNode): """Activates the outputs depending of the value. If the "value" is equal to "case 1", the output "case 1" will be activated. @output Default: Activated if the input value does not match any case. """ bl_idname = 'LNSwitchNode' bl_label = 'Switch Output' lnx_version = 4 min_inputs = 2 def __init__(self): super(SwitchNode, self).__init__() array_nodes[self.get_id_str()] = self def lnx_init(self, context): self.add_input('LnxNodeSocketAction', 'In') self.add_input('LnxDynamicSocket', 'Value') self.add_output('LnxNodeSocketAction', 'Default') def draw_buttons(self, context, layout): row = layout.row(align=True) op = row.operator('lnx.node_add_input_output', text='New', icon='PLUS', emboss=True) op.node_index = self.get_id_str() op.in_socket_type = 'LnxDynamicSocket' op.out_socket_type = 'LnxNodeSocketAction' op.in_name_format = 'Case {0}' op.out_name_format = 'Case {0}' op.in_index_name_offset = -1 op.out_index_name_offset = -1 column = row.column(align=True) op = column.operator('lnx.node_remove_input_output', text='', icon='X', emboss=True) op.node_index = self.get_id_str() if len(self.inputs) == self.min_inputs: column.enabled = False def get_replacement_node(self, node_tree: bpy.types.NodeTree): if self.lnx_version not in (0, 3): raise LookupError() return NodeReplacement.Identity(self)