class DiTriggers(DiSkillV2):
def __init__(self, brain):
super().__init__()
self.triggers: UniqueItemsPriorityQue = UniqueItemsPriorityQue()
self.is_recording: bool = False
self.brain: Brain = brain
self.new_cmd: str = ""
def input(self, ear, skin, eye):
if not self.is_recording:
if ear:
self.new_cmd = ear
self.is_recording = True # not recording and hear something so record
else:
if self.brain.getLogicChobitOutput():
self.triggers.insert(self.new_cmd)
self.is_recording = False
# trigger output (can add alternative code to do this automatically)
if ear == "random trigger":
self.setSimpleAlg(self.triggers.getRNDElement())