When using the Gate node,
it could be useful to have Out for True and also for False.
Otherwise we need to use 2 gates instead of only one. Am I true ?
When using the Gate node,
it could be useful to have Out for True and also for False.
Otherwise we need to use 2 gates instead of only one. Am I true ?
Heyo!
Depending on what you need, Branch
node may also come handy:
Hello @lubos
it’s for example to simplify all gates (like therafter in this picture)
in only one gate with 2 ouptputs as we often need this …
looks like a Case Of or Switch
In case you are interested, thereafter is the code to do it yourself
I named it “GateTFNode” for “Gate True/False Node”
The look&feel you will obtain :
For your blender.py
class GateTFNode (Node, ArmLogicTreeNode):
‘’‘Gate node avec True et False’’’
bl_idname = ‘LNGateTFNode’
bl_label = ‘GateTF’
bl_icon = ‘CURVE_PATH’
property0 = EnumProperty(
items = [(‘Equal’, ‘Equal’, ‘Equal’),
(‘Not Equal’, ‘Not Equal’, ‘Not Equal’),
(‘Greater’, ‘Greater’, ‘Greater’),
(‘Greater Equal’, ‘Greater Equal’, ‘Greater Equal’),
(‘Less’, ‘Less’, ‘Less’),
(‘Less Equal’, ‘Less Equal’, ‘Less Equal’),
(‘Or’, ‘Or’, ‘Or’),
(‘And’, ‘And’, ‘And’)],
name=’’, default=‘Equal’)
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketShader', 'Value')
self.inputs.new('NodeSocketShader', 'Value')
self.outputs.new('ArmNodeSocketAction', 'True')
self.outputs.new('ArmNodeSocketAction', 'False')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
Then for your GateTFNode.hx
package armory.logicnode;
class GateTFNode extends LogicNode {
public var property0:String;
public function new(tree:LogicTree) {
super(tree);
}
override function run() {
var v1:Dynamic = inputs[1].get();
var v2:Dynamic = inputs[2].get();
var cond = false;
switch (property0) {
case "Equal":
cond = v1 == v2;
case "Not Equal":
cond = v1 != v2;
case "Greater":
cond = v1 > v2;
case "Greater Equal":
cond = v1 >= v2;
case "Less":
cond = v1 < v2;
case "Less Equal":
cond = v1 <= v2;
case "Or":
cond = v1 || v2;
case "And":
cond = v1 && v2;
}
//if (cond) super.run();
cond ? runOutputs(0) : runOutputs(1);
}
}