2
from bee.segments import *
3
from bee.types import stringtupleparser
7
The compare assessor compares two input values
11
"autocreate" : {"type_" : "bool"},
16
f.type_.type = "option"
17
f.type_.options = "bool", "int", "float", "(str,identifier)", "(str,action)", "(str,keycode)", "(str,message)", "(str,property)", "(str,process)", "str", "(object,matrix)", "(object,bge)", "object", "custom"
18
f.type_.optiontitles = "Bool", "Integer", "Float", "ID String", "Action String", "Key String", "Message String", "Property String", "Process ID String", "Generic String", "Matrix Object", "BGE Object", "Generic Object", "Custom"
19
f.type_.default = "bool"
21
def __new__(cls, type_):
22
type_ = stringtupleparser(type_)
23
class compare(bee.worker):
27
mode = variable("str")
28
parameter(mode, "equal")
31
inp1 = antenna("pull", type_)
32
inp2 = antenna("pull", type_)
33
# One output value returning the result of the comparision
34
outp = output("pull", "bool")
35
result = variable("bool")
38
# Whenever the result of the comparison is requested..
39
# ...pull in the input values...
40
b_inp1 = buffer("pull", type_)
42
pretrigger(result, b_inp1)
43
b_inp2 = buffer("pull", type_)
45
pretrigger(result, b_inp2)
47
# ...and then compare the values
50
if self.mode == "equal":
51
result = (self.b_inp1 == self.b_inp2)
52
elif self.mode == "greater":
53
result = (self.b_inp1 > self.b_inp2)
54
elif self.mode == "lesser":
55
result = (self.b_inp1 < self.b_inp2)
57
pretrigger(result, do_compare)
59
# Specify names for the comparison mode
63
f.mode.type = "option"
64
f.mode.options = "equal", "greater", "lesser"
65
f.mode.optiontitles = "EqualTo", "GreaterThan", "LesserThan"
68
"inp1" : {"name": "Input 1"},
69
"inp2" : {"name": "Input 2"},
70
"outp" : {"name": "Output"},
b'\\ No newline at end of file'