43 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from lnx.logicnode.lnx_nodes import *
 | |
| 
 | |
| 
 | |
| class CallFunctionNode(LnxLogicTreeNode):
 | |
|     """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.'
 | |
|     lnx_section = 'function'
 | |
|     lnx_version = 2
 | |
|     min_inputs = 3
 | |
| 
 | |
|     def __init__(self, *args, **kwargs):
 | |
|         super(CallFunctionNode, self).__init__(*args, **kwargs)
 | |
|         array_nodes[str(id(self))] = self
 | |
| 
 | |
|     def lnx_init(self, context):
 | |
|         self.add_input('LnxNodeSocketAction', 'In')
 | |
|         self.add_input('LnxDynamicSocket', 'Trait/Any')
 | |
|         self.add_input('LnxStringSocket', 'Function')
 | |
| 
 | |
|         self.add_output('LnxNodeSocketAction', 'Out')
 | |
|         self.add_output('LnxDynamicSocket', 'Result')
 | |
| 
 | |
|     def draw_buttons(self, context, layout):
 | |
|         row = layout.row(align=True)
 | |
|         op = row.operator('lnx.node_add_input', 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 = -2
 | |
|         column = row.column(align=True)
 | |
|         op = column.operator('lnx.node_remove_input', text='', icon='X', emboss=True)
 | |
|         op.node_index = str(id(self))
 | |
|         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, 1):
 | |
|             raise LookupError()
 | |
|             
 | |
|         return NodeReplacement.Identity(self)
 |