armory/blender/arm/logicnode/logic/LN_call_function.py
Moritz Brückner 96aa0ee890 Use custom sockets for default data types
This allows to listen for socket updates for the live patch system
2021-07-10 21:46:44 +02:00

34 lines
1.3 KiB
Python

from arm.logicnode.arm_nodes import *
class CallFunctionNode(ArmLogicTreeNode):
"""Calls the given function that was created by the [Function](#function) node."""
bl_idname = 'LNCallFunctionNode'
bl_label = 'Call Function'
bl_description = 'Calls a function that was created by the Function node.'
arm_section = 'function'
arm_version = 1
min_inputs = 3
def __init__(self):
super(CallFunctionNode, self).__init__()
array_nodes[str(id(self))] = self
def init(self, context):
super(CallFunctionNode, self).init(context)
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmDynamicSocket', 'Trait/Any')
self.add_input('ArmStringSocket', 'Function')
self.add_output('ArmNodeSocketAction', 'Out')
self.add_output('ArmDynamicSocket', 'Result')
def draw_buttons(self, context, layout):
row = layout.row(align=True)
op = row.operator('arm.node_add_input', text='Add Arg', icon='PLUS', emboss=True)
op.node_index = str(id(self))
op.socket_type = 'ArmDynamicSocket'
op.name_format = "Arg {0}"
op.index_name_offset = -2
op2 = row.operator('arm.node_remove_input', text='', icon='X', emboss=True)
op2.node_index = str(id(self))