Merge pull request #1999 from knowledgenude/master

Value Changed node
This commit is contained in:
Lubos Lenco 2020-11-10 13:04:29 +01:00 committed by GitHub
commit 13d9a890d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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)