armory/Sources/armory/logicnode/ArrayAddUniqueNode.hx

23 lines
422 B
Haxe
Raw Normal View History

2017-11-27 09:40:30 +01:00
package armory.logicnode;
class ArrayAddUniqueNode extends LogicNode {
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-11-27 09:40:30 +01: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;
2019-12-19 23:54:08 +01:00
2018-06-12 23:48:01 +02:00
if (inputs.length > 2) {
for (i in 2...inputs.length) {
2019-12-19 23:54:08 +01:00
var value: Dynamic = inputs[i].get();
2018-06-12 23:48:01 +02:00
if (ar.indexOf(value) == -1) ar.push(value);
}
}
2017-11-27 09:40:30 +01:00
2018-10-22 10:10:33 +02:00
runOutput(0);
2017-11-27 09:40:30 +01:00
}
}