armory/blender/arm/logicnode/logic_function.py
Zicklag f00b72836b Add Functions and Function Calls to Logic Nodes
* Renamed Call Haxe node to Call Function because it will now be able
to call node functions as well.
 * Added ability to pass arguments to the Call Function node.
 * Created Function and Function output nodes that allow you to create
functions in node trees. Node functions can be called from other nodes
and from Haxe.
2018-11-04 09:00:38 -06:00

34 lines
1 KiB
Python

import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class FunctionNode(Node, ArmLogicTreeNode):
'''Function node'''
bl_idname = 'LNFunctionNode'
bl_label = 'Function'
bl_icon = 'CURVE_PATH'
min_outputs = 1
def __init__(self):
array_nodes[str(id(self))] = self
def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
function_name = StringProperty(name="Name")
def draw_buttons(self, context, layout):
row = layout.row(align=True)
row.prop(self, 'function_name')
row = layout.row(align=True)
op = row.operator('arm.node_add_output', text='Add Arg', icon='PLUS', emboss=True)
op.node_index = str(id(self))
op.socket_type = 'NodeSocketShader'
op.name_format = "Arg {0}"
op.index_name_offset = 0
op2 = row.operator('arm.node_remove_output', text='', icon='X', emboss=True)
op2.node_index = str(id(self))
add_node(FunctionNode, category='Logic')