Maybe you would like as me
to have this
inspite of the standard one
Why ? because getting the indice is usefull to make something to happen according to some special indices, as for example during a test to change colors of objects.
But it is not available today in standard in the Array Loop and if you want to do it with the Loop node, it adds lot of lines between nodes.
Before having it in the standard list of nodes, making your own node could be as this
1/ The blender.py
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
import arm.nodes_logic
class ArrayLoopIndiceNode(Node, ArmLogicTreeNode):
‘’‘ArrayLoop node avec indice’’’
bl_idname = ‘LNArrayLoopIndiceNode’
bl_label = ‘Array Loop Indice’
bl_icon = ‘CURVE_PATH’
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketShader', 'Array')
self.outputs.new('ArmNodeSocketAction', 'Loop')
self.outputs.new('NodeSocketInt', 'Value')
self.outputs.new('ArmNodeSocketAction', 'Done')
self.outputs.new('NodeSocketInt', 'Indice')
def register():
# Add custom nodes
add_node(ArrayLoopIndiceNode, category=‘Logic’)
# Register newly added nodes
arm.nodes_logic.register_nodes()
2/ the ArrayLoopIndiceNode.hx
package armory.logicnode;
class ArrayLoopIndiceNode extends LogicNode {
var value:Dynamic;
var index:Int;
public function new(tree:LogicTree) {
super(tree);
}
override function run() {
var ar:Array<Dynamic> = inputs[1].get();
index = 0;
for (val in ar) {
value = val;
index = index +1;
runOutputs(0);
}
runOutputs(2);
}
override function get(from:Int):Dynamic {
if (from == 1) return value;
else if (from == 3) return index;
else return index;
}
}