955331a5 by Barry

Fixed some commands and improved error handling

1 parent 140433fd
......@@ -43,16 +43,8 @@ class CommandHandler(object):
with open('commands/{}.txt'.format(ldict['next_command']), 'r', encoding='utf-8') as f:
exec(f.read())
return True
except FileNotFoundError as e:
print(e)
mud.send_message(id, "Unknown command '{}'".format(cmd))
return False
except AttributeError as e:
print(e)
mud.send_message(id, "Unknown command '{}'".format(cmd))
return False
except Exception as e:
print('Something terrible happened...')
print('Something happened...')
print(e)
mud.send_message(id, "Unknown command '{}'".format(cmd))
return False
......
def inventory(id, players, mud):
mud.send_message(id, '\r\n-Item----------=Inventory=-----------Qty-\r\n')
for item, qty in players[id]['inventory'].items():
mud.send_message(id, '{} {}'.format(item.ljust(37), qty))
mud.send_message(id, '{} {}'.format("%-37s" % item, qty))
mud.send_message(id, '\r\n-----------------------------------------')
inventory(id, players, mud)
\ No newline at end of file
......
def who(self):
self.mud.send_message(self.id, "")
self.mud.send_message(self.id, "-------- {} Players Currently Online --------".format(len(self.players)))
for pid, player in self.players.items():
self.mud.send_message(self.id, " " + player["name"])
self.mud.send_message(self.id, "---------------------------------------------".format(len(self.players)))
self.mud.send_message(self.id, "")
who(self)
\ No newline at end of file
def who(id, players, mud):
mud.send_message(id, "")
mud.send_message(id, "-------- {} Players Currently Online --------".format(len(players)))
for pid, player in players.items():
mud.send_message(id, " " + player["name"])
mud.send_message(id, "---------------------------------------------".format(len(players)))
mud.send_message(id, "")
who(id, players, mud)
\ No newline at end of file
......
......@@ -57,6 +57,7 @@ def prompt(pid):
while True:
if 'esp' in sys.platform:
gc.collect()
print(flash_button.value())
if flash_button.value() == 0:
break
# pause for 1/5 of a second on each loop, so that we don't constantly
......