Fix ArrayLoopNode socket (dynamic value) + add "Index" output
This commit is contained in:
parent
0ac46b3bb5
commit
a9d2a10d0b
|
@ -3,6 +3,7 @@ package armory.logicnode;
|
|||
class ArrayLoopNode extends LogicNode {
|
||||
|
||||
var value: Dynamic;
|
||||
var index: Int;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
|
@ -12,8 +13,10 @@ class ArrayLoopNode extends LogicNode {
|
|||
var ar: Array<Dynamic> = inputs[1].get();
|
||||
if (ar == null) return;
|
||||
|
||||
index = -1;
|
||||
for (val in ar) {
|
||||
value = val;
|
||||
index++;
|
||||
runOutput(0);
|
||||
|
||||
if (tree.loopBreak) {
|
||||
|
@ -21,10 +24,12 @@ class ArrayLoopNode extends LogicNode {
|
|||
break;
|
||||
}
|
||||
}
|
||||
runOutput(2);
|
||||
runOutput(3);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return value;
|
||||
if (from == 1)
|
||||
return value;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,13 @@ class ArrayLoopNode(Node, ArmLogicTreeNode):
|
|||
bl_idname = 'LNArrayLoopNode'
|
||||
bl_label = 'Array Loop'
|
||||
bl_icon = 'CURVE_PATH'
|
||||
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('ArmNodeSocketArray', 'Array')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Loop')
|
||||
self.outputs.new('NodeSocketInt', 'Value')
|
||||
self.outputs.new('NodeSocketShader', 'Value')
|
||||
self.outputs.new('NodeSocketInt', 'Index')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Done')
|
||||
|
||||
add_node(ArrayLoopNode, category='Logic')
|
||||
|
|
Loading…
Reference in a new issue