value-changed-node

This commit is contained in:
knowledgenude 2020-11-08 17:37:50 -03:00
parent d210cea6d8
commit fde59db1e5
2 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,25 @@
package armory.logicnode;
class ValueChangedNode extends LogicNode {
var initial: Dynamic;
var value: Dynamic;
public function new(tree: LogicTree) {
super(tree);
}
override function run(from: Int) {
if (initial == null) {
initial = inputs[1].get();
value = initial;
}
else if (value != inputs[1].get()) {
value = inputs[1].get();
value != initial ? runOutput(0) : runOutput(1);
}
}
}

View file

@ -0,0 +1,16 @@
from arm.logicnode.arm_nodes import *
class ValueChangedNode(ArmLogicTreeNode):
"""Sends a signal to `Changed` output whether the connected value is changed and a signal to `Unchanged` if the connected value returns to initial. Does not works with `null` value."""
bl_idname = 'LNValueChangedNode'
bl_label = 'Value Changed'
arm_version = 1
def init(self, context):
super(ValueChangedNode, self).init(context)
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('NodeSocketShader', 'Value')
self.add_output('ArmNodeSocketAction', 'Changed')
self.add_output('ArmNodeSocketAction', 'Unchanged')
add_node(ValueChangedNode, category=PKG_AS_CATEGORY)