diff --git a/game.py b/game.py index 40b4d7a..74aa9fc 100644 --- a/game.py +++ b/game.py @@ -454,7 +454,7 @@ class Game: elif text == 'You are no longer AFK.': self.g.afk = False - match1 = re.match(r'<(\w+)> (.*)', text) + match1 = re.match(r' (.*)', text) match2 = re.match(r'\[(\w+) -> me] (.*)', text) if match1: sender, text = match1.groups() @@ -780,6 +780,33 @@ class Game: else: reply = 'no path' + if command == 'goto': + try: + data = data.replace('(', ' ').replace(')', ' ').replace(',', ' ') + x2, y2, z2 = [int(x) for x in data.split()] + except (AttributeError, ValueError): + reply = 'usage: !goto x y z' + + if not reply: + pos = utils.pint(self.g.pos) + goal = utils.pint((x2, y2, z2)) + start = time.time() + navpath = self.g.world.path_to_place(pos, goal) + + if navpath: + self.g.path = navpath + if self.g.job: + self.g.job.stop() + print(len(navpath)) + print(navpath) + print(round(time.time() - start, 3), 'seconds') + if self.g.job: + self.g.job.stop() + self.g.look_at = None + reply = 'ok' + else: + reply = 'no path' + if command == 'break': self.break_block(blocks.TEST_BLOCK) reply = 'ok'