Array length node

This commit is contained in:
Lubos Lenco 2017-11-02 23:32:36 +01:00
parent cb19f9d1d9
commit 7fed0a24c9
3 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,13 @@
package armory.logicnode;
class ArrayLengthNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function get(from:Int):Dynamic {
var ar:Array<Dynamic> = inputs[0].get();
return ar != null ? ar.length : 0;
}
}

View file

@ -0,0 +1,16 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class ArrayLengthNode(Node, ArmLogicTreeNode):
'''Array length node'''
bl_idname = 'LNArrayLengthNode'
bl_label = 'Array Length'
bl_icon = 'GAME'
def init(self, context):
self.inputs.new('NodeSocketShader', 'Array')
self.outputs.new('NodeSocketInt', 'Length')
add_node(ArrayGetNode, category='Array')