Files
LNXSDK/leenkx/blender/lnx/logicnode/signal/LN_on_signal.py

45 lines
1.4 KiB
Python

from lnx.logicnode.lnx_nodes import *
class OnSignalNode(LnxLogicTreeNode):
"""Activates the output when the given Signal emits.
Connect a Signal instance to the input. When that Signal emits,
the output is activated and emitted arguments are available on
the dynamic output sockets.
Use 'Add Arg' to add output sockets for receiving emitted data.
@seeNode Signal
@seeNode Emit Signal"""
bl_idname = 'LNOnSignalNode'
bl_label = 'On Signal'
lnx_version = 1
lnx_section = 'signal'
min_outputs = 1
def __init__(self, *args, **kwargs):
super(OnSignalNode, self).__init__(*args, **kwargs)
array_nodes[str(id(self))] = self
def lnx_init(self, context):
self.add_input('LnxDynamicSocket', 'Signal')
self.add_output('LnxNodeSocketAction', 'Out')
def draw_buttons(self, context, layout):
row = layout.row(align=True)
op = row.operator('lnx.node_add_output', text='Add Arg', icon='PLUS', emboss=True)
op.node_index = str(id(self))
op.socket_type = 'LnxDynamicSocket'
op.name_format = "Arg {0}"
op.index_name_offset = 0
column = row.column(align=True)
op = column.operator('lnx.node_remove_output', text='', icon='X', emboss=True)
op.node_index = str(id(self))
if len(self.outputs) == self.min_outputs:
column.enabled = False