Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Barry
/
esp8266-Mud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
955331a5
authored
2018-05-01 12:30:16 -0700
by
Barry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Fixed some commands and improved error handling
1 parent
140433fd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
18 deletions
commandhandler.py
commands/inventory.txt
commands/who.txt
main.py
commandhandler.py
View file @
955331a
...
...
@@ -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
...
...
commands/inventory.txt
View file @
955331a
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
...
...
commands/who.txt
View file @
955331a
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
...
...
main.py
View file @
955331a
...
...
@@ -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
...
...
Please
register
or
sign in
to post a comment