优化蓝图

This commit is contained in:
boyce
2026-03-12 16:54:43 +08:00
parent f3acdc860c
commit f89232c2dd
2 changed files with 33 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ func (bm *Blueprint) regSysNodes() {
bm.RegisterExecNode(NewExecNode[CreateTimer]())
bm.RegisterExecNode(NewExecNode[AppendIntReturn]())
bm.RegisterExecNode(NewExecNode[AppendStringReturn]())
bm.RegisterExecNode(NewExecNode[IntInArray]())
}

View File

@@ -780,5 +780,37 @@ func (em *AppendStringReturn) Exec() (int, error) {
}
returnPort.AppendArrayValStr(val)
return -0, nil
}
// IntInArray 判断整型值是否在整型数组中
type IntInArray struct {
BaseExecNode
}
func (em *IntInArray) GetName() string {
return "IntInArray"
}
func (em *IntInArray) Exec() (int, error) {
val, ok := em.GetInPortInt(1)
if !ok {
return -1, fmt.Errorf("IntInArray inParam 1 not found")
}
array, ok := em.GetInPortArray(2)
if !ok {
return -1, fmt.Errorf("IntInArray inParam 0 not found")
}
bFind := false
for i := range array {
if array[i].IntVal == val {
bFind = true
break
}
}
em.SetOutPortBool(1,bFind)
return -0, nil
}