Add goto command
This commit is contained in:
parent
afa588d843
commit
e4b51aa2d6
29
game.py
29
game.py
|
@ -454,7 +454,7 @@ class Game:
|
||||||
elif text == 'You are no longer AFK.':
|
elif text == 'You are no longer AFK.':
|
||||||
self.g.afk = False
|
self.g.afk = False
|
||||||
|
|
||||||
match1 = re.match(r'<(\w+)> (.*)', text)
|
match1 = re.match(r'<?(\w+)> (.*)', text)
|
||||||
match2 = re.match(r'\[(\w+) -> me] (.*)', text)
|
match2 = re.match(r'\[(\w+) -> me] (.*)', text)
|
||||||
if match1:
|
if match1:
|
||||||
sender, text = match1.groups()
|
sender, text = match1.groups()
|
||||||
|
@ -780,6 +780,33 @@ class Game:
|
||||||
else:
|
else:
|
||||||
reply = 'no path'
|
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':
|
if command == 'break':
|
||||||
self.break_block(blocks.TEST_BLOCK)
|
self.break_block(blocks.TEST_BLOCK)
|
||||||
reply = 'ok'
|
reply = 'ok'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user