Files
LNXSDK/leenkx/Sources/leenkx/logicnode/ValueChangedNode.hx
2025-01-22 16:18:30 +01:00

38 lines
621 B
Haxe

package leenkx.logicnode;
class ValueChangedNode extends LogicNode {
var initialized = false;
var initialValue: Dynamic;
var lastValue: Dynamic;
public function new(tree: LogicTree) {
super(tree);
}
override function run(from: Int) {
var currentValue = inputs[1].get();
if (!initialized) {
initialValue = currentValue;
lastValue = initialValue;
initialized = true;
runOutput(0);
runOutput(2);
return;
}
if (currentValue == lastValue) {
runOutput(1);
}
else {
lastValue = currentValue;
runOutput(0);
}
if (currentValue == initialValue) {
runOutput(2);
}
}
}