A new Array Loop node with Indice can help for test and more

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;
	
}

}

Very nice!!
Can you submit it to the community nodes repository? https://github.com/armory3d/logic_pack
You only need to add your class and register-line to the python file and put the Haxe one in the right folder.
(There you can also find a Inverse, To Bool and Min/Max node from me :slight_smile:)

Ok , done.
Good solution to start the place where to find/share new nodes proposals.
Thanks

Are you sure you did it the right way? You need to fork the repository, commit your changes to it (the online editor should be enough for copy-pasting the code into the python file, and there is a button for adding a new file) and then do a pull request back to the original one.
Currently your changes don’t show up, and there is no pull request pending.

houps … is it ok now ?

I still can’t find it on the link I send…

visible now …:tada: