armory/blender/arm/logicnode/array/LN_array_add.py

37 lines
1.4 KiB
Python
Raw Normal View History

2017-04-04 23:11:31 +02:00
from arm.logicnode.arm_nodes import *
class ArrayAddNode(ArmLogicTreeNode):
2020-10-05 19:55:56 +02:00
"""Adds the given value to the given array.
2020-09-28 15:58:41 +02:00
@input Array: the array to manipulate.
@input Modify Original: if `false`, the input array is copied before adding the value.
@input Unique Values: if `true`, values may occur only once in that array (only primitive data types are supported).
"""
2017-04-04 23:11:31 +02:00
bl_idname = 'LNArrayAddNode'
bl_label = 'Array Add'
arm_version = 1
2017-04-04 23:11:31 +02:00
2018-06-12 23:48:01 +02:00
def __init__(self):
array_nodes[str(id(self))] = self
2017-04-04 23:11:31 +02:00
def init(self, context):
super(ArrayAddNode, self).init(context)
2020-09-08 21:49:02 +02:00
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmNodeSocketArray', 'Array')
self.add_input('NodeSocketBool', 'Modify Original', default_value=True)
2020-09-28 15:58:41 +02:00
self.add_input('NodeSocketBool', 'Unique Values')
2020-09-08 21:49:02 +02:00
self.add_input('NodeSocketShader', 'Value')
self.add_output('ArmNodeSocketAction', 'Out')
self.add_output('ArmNodeSocketArray', 'Array')
2017-04-04 23:11:31 +02:00
2018-06-12 23:48:01 +02:00
def draw_buttons(self, context, layout):
row = layout.row(align=True)
op = row.operator('arm.node_add_input_value', text='Add Input', icon='PLUS', emboss=True)
2018-06-12 23:48:01 +02:00
op.node_index = str(id(self))
op.socket_type = 'NodeSocketShader'
op2 = row.operator('arm.node_remove_input_value', text='', icon='X', emboss=True)
op2.node_index = str(id(self))
add_node(ArrayAddNode, category=PKG_AS_CATEGORY)