Fixed some commands and improved error handling
Showing
4 changed files
with
11 additions
and
18 deletions
... | @@ -43,16 +43,8 @@ class CommandHandler(object): | ... | @@ -43,16 +43,8 @@ class CommandHandler(object): |
43 | with open('commands/{}.txt'.format(ldict['next_command']), 'r', encoding='utf-8') as f: | 43 | with open('commands/{}.txt'.format(ldict['next_command']), 'r', encoding='utf-8') as f: |
44 | exec(f.read()) | 44 | exec(f.read()) |
45 | return True | 45 | return True |
46 | except FileNotFoundError as e: | ||
47 | print(e) | ||
48 | mud.send_message(id, "Unknown command '{}'".format(cmd)) | ||
49 | return False | ||
50 | except AttributeError as e: | ||
51 | print(e) | ||
52 | mud.send_message(id, "Unknown command '{}'".format(cmd)) | ||
53 | return False | ||
54 | except Exception as e: | 46 | except Exception as e: |
55 | print('Something terrible happened...') | 47 | print('Something happened...') |
56 | print(e) | 48 | print(e) |
57 | mud.send_message(id, "Unknown command '{}'".format(cmd)) | 49 | mud.send_message(id, "Unknown command '{}'".format(cmd)) |
58 | return False | 50 | return False | ... | ... |
1 | def inventory(id, players, mud): | 1 | def inventory(id, players, mud): |
2 | mud.send_message(id, '\r\n-Item----------=Inventory=-----------Qty-\r\n') | 2 | mud.send_message(id, '\r\n-Item----------=Inventory=-----------Qty-\r\n') |
3 | for item, qty in players[id]['inventory'].items(): | 3 | for item, qty in players[id]['inventory'].items(): |
4 | mud.send_message(id, '{} {}'.format(item.ljust(37), qty)) | 4 | mud.send_message(id, '{} {}'.format("%-37s" % item, qty)) |
5 | mud.send_message(id, '\r\n-----------------------------------------') | 5 | mud.send_message(id, '\r\n-----------------------------------------') |
6 | 6 | ||
7 | inventory(id, players, mud) | 7 | inventory(id, players, mud) |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | def who(self): | ||
2 | self.mud.send_message(self.id, "") | ||
3 | self.mud.send_message(self.id, "-------- {} Players Currently Online --------".format(len(self.players))) | ||
4 | for pid, player in self.players.items(): | ||
5 | self.mud.send_message(self.id, " " + player["name"]) | ||
6 | self.mud.send_message(self.id, "---------------------------------------------".format(len(self.players))) | ||
7 | self.mud.send_message(self.id, "") | ||
8 | who(self) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | def who(id, players, mud): | ||
2 | mud.send_message(id, "") | ||
3 | mud.send_message(id, "-------- {} Players Currently Online --------".format(len(players))) | ||
4 | for pid, player in players.items(): | ||
5 | mud.send_message(id, " " + player["name"]) | ||
6 | mud.send_message(id, "---------------------------------------------".format(len(players))) | ||
7 | mud.send_message(id, "") | ||
8 | who(id, players, mud) | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -57,6 +57,7 @@ def prompt(pid): | ... | @@ -57,6 +57,7 @@ def prompt(pid): |
57 | while True: | 57 | while True: |
58 | if 'esp' in sys.platform: | 58 | if 'esp' in sys.platform: |
59 | gc.collect() | 59 | gc.collect() |
60 | print(flash_button.value()) | ||
60 | if flash_button.value() == 0: | 61 | if flash_button.value() == 0: |
61 | break | 62 | break |
62 | # pause for 1/5 of a second on each loop, so that we don't constantly | 63 | # pause for 1/5 of a second on each loop, so that we don't constantly | ... | ... |
-
Please register or sign in to post a comment