Fix reference error in get_input. Resolves #1219.
This commit is contained in:
parent
a651490565
commit
865ab131bb
1 changed files with 20 additions and 16 deletions
|
|
@ -888,24 +888,28 @@ class CmdGetInput(Command):
|
||||||
def func(self):
|
def func(self):
|
||||||
"This is called when user enters anything."
|
"This is called when user enters anything."
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
callback = caller.ndb._getinput._callback
|
try:
|
||||||
if not callback:
|
getinput = caller.ndb._getinput
|
||||||
# this can be happen if called from a player-command when IC
|
if not getinput and hasattr(caller, "player"):
|
||||||
caller = self.player
|
getinput = caller.player.ndb._getinput
|
||||||
callback = caller.ndb._getinput._callback
|
caller = caller.player
|
||||||
if not callback:
|
callback = getinput._callback
|
||||||
raise RuntimeError("No input callback found.")
|
|
||||||
|
|
||||||
caller.ndb._getinput._session = self.session
|
caller.ndb._getinput._session = self.session
|
||||||
prompt = caller.ndb._getinput._prompt
|
prompt = caller.ndb._getinput._prompt
|
||||||
result = self.raw_string.strip() # we strip the ending line break caused by sending
|
result = self.raw_string.strip() # we strip the ending line break caused by sending
|
||||||
|
|
||||||
ok = not callback(caller, prompt, result)
|
ok = not callback(caller, prompt, result)
|
||||||
if ok:
|
if ok:
|
||||||
# only clear the state if the callback does not return
|
# only clear the state if the callback does not return
|
||||||
# anything
|
# anything
|
||||||
del caller.ndb._getinput
|
del caller.ndb._getinput
|
||||||
caller.cmdset.remove(InputCmdSet)
|
caller.cmdset.remove(InputCmdSet)
|
||||||
|
except Exception:
|
||||||
|
# make sure to clean up cmdset if something goes wrong
|
||||||
|
caller.msg("|rError in get_input. Choice not confirmed (report to admin)|n")
|
||||||
|
logger.log_trace("Error in get_input")
|
||||||
|
caller.cdmset.remove(InputCmdSet)
|
||||||
|
|
||||||
|
|
||||||
class InputCmdSet(CmdSet):
|
class InputCmdSet(CmdSet):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue