Add error handling to handler
This commit is contained in:
parent
832e26232b
commit
9fc4ed130c
|
@ -9,7 +9,20 @@ class Handler(npyscreen.ButtonPress):
|
||||||
3: re-render the screen
|
3: re-render the screen
|
||||||
"""
|
"""
|
||||||
def whenPressed(self):
|
def whenPressed(self):
|
||||||
self.parent.update_log(self.parent.dialogueBox.value)
|
# This is the raw command from the user
|
||||||
|
raw_command = self.parent.dialogueBox.value
|
||||||
|
|
||||||
|
# This is the raw command from the user
|
||||||
|
parsed_command = raw_command.split()
|
||||||
|
|
||||||
|
try:
|
||||||
|
command = parsed_command.pop(0)
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
arguments = parsed_command
|
||||||
|
|
||||||
|
self.parent.update_log('command: ' + command)
|
||||||
|
self.parent.update_log('args: {0}'.format(arguments))
|
||||||
self.parent.dialogueBox.value = ''
|
self.parent.dialogueBox.value = ''
|
||||||
self.parent.artContent.display()
|
self.parent.artContent.display()
|
||||||
self.parent.parentApp.switchForm('GAME')
|
self.parent.parentApp.switchForm('GAME')
|
||||||
|
|
Loading…
Reference in New Issue