armory/Sources/armory/logicnode/ArrayLoopNode.hx

36 lines
546 B
Haxe
Raw Normal View History

2017-04-04 23:11:31 +02:00
package armory.logicnode;
2017-04-08 20:05:35 +02:00
class ArrayLoopNode extends LogicNode {
2017-04-04 23:11:31 +02:00
2019-12-19 23:54:08 +01:00
var value: Dynamic;
var index: Int;
2017-04-04 23:11:31 +02:00
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-04 23:11:31 +02:00
super(tree);
}
2019-12-19 23:54:08 +01:00
override function run(from: Int) {
var ar: Array<Dynamic> = inputs[1].get();
2018-06-14 14:52:05 +02:00
if (ar == null) return;
index = -1;
2017-04-04 23:11:31 +02:00
for (val in ar) {
value = val;
index++;
2018-10-22 10:10:33 +02:00
runOutput(0);
2018-11-13 19:47:26 +01:00
if (tree.loopBreak) {
tree.loopBreak = false;
break;
}
2017-04-04 23:11:31 +02:00
}
runOutput(3);
2017-04-04 23:11:31 +02:00
}
2019-12-19 23:54:08 +01:00
override function get(from: Int): Dynamic {
if (from == 1)
return value;
return index;
2017-04-04 23:11:31 +02:00
}
}