def setup(self): sb = self.blackboard.bot_standing_on_block(self.blackboard.bot_object) while sb is None: yield utils.reactor_break() sb = self.blackboard.bot_standing_on_block(self.blackboard.bot_object) else: if self.travel_multiple_goals is not None: d = cooperate(AStarMultiCoords(dimension=self.blackboard.dimension, start_coords=sb.coords, goal_coords=self.travel_coords, multiple_goals=self.travel_multiple_goals)).whenDone() elif self.travel_coords is not None: d = cooperate(AStarCoords(dimension=self.blackboard.dimension, start_coords=sb.coords, goal_coords=self.travel_coords)).whenDone() else: d = cooperate(AStarBBCol(dimension=self.blackboard.dimension, start_coords=sb.coords, bb=self.travel_bb)).whenDone() d.addErrback(logbot.exit_on_error) astar = yield d if astar.path is not None: current_start = self.blackboard.bot_standing_on_block(self.blackboard.bot_object) if sb == current_start: self.path = astar.path if self.shorten_path_by > 0: self.path = self.path[self.shorten_path_by:] self.start_coords = current_start.coords
def run(self): self.running = True try: while 1: yield utils.reactor_break() self.check_new_command() g = self.current_behaviour if g.status == Status.running: yield g.tick() self.bot.bot_object.hold_position_flag = g.hold_position_flag # if g.cancelled: # break if g.status == Status.running: break elif g.status == Status.suspended: continue else: self.leaf_to_parent() except: if self.current_behaviour: msg = "I want to try %s, but my brain hurts." msg = msg % self.current_behaviour.name else: msg = "I'm not even doing anything and my brain hurts." log.msg(msg) log.err() self.world.chat.send_message(msg) self.cancel_running(Priorities.absolute_top) self.running = False
def run(self): self.running = True try: while 1: yield utils.reactor_break() self.check_new_command() g = self.current_behaviour if g.status == Status.running: yield g.tick() self.bot.bot_object.hold_position_flag = g.hold_position_flag if g.cancelled: break elif g.status == Status.running: break elif g.status == Status.suspended: continue else: self.leaf_to_parent() except: logbot.exit_on_error() self.running = False
def run(self): self.running = True try: while True: yield utils.reactor_break() self.check_new_command() b = self.current_behavior self.bot.bot_object.hold_position_flag = b.hold_position_flag if b.sleep_until > self.blackboard.world_current_tick: break if b.status == Status.running: yield b.tick() if b.cancelled: break elif b.status == Status.running: break elif b.status == Status.suspended: continue else: self.child_to_parent() except: logbot.exit_on_error() self.running = False