value-changed-node
This commit is contained in:
parent
d210cea6d8
commit
fde59db1e5
25
Sources/armory/logicnode/ValueChangedNode.hx
Normal file
25
Sources/armory/logicnode/ValueChangedNode.hx
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
16
blender/arm/logicnode/logic/LN_value_changed.py
Normal file
16
blender/arm/logicnode/logic/LN_value_changed.py
Normal 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)
|
Loading…
Reference in a new issue