From 4327bc48d3f4384de4c5c42164a9c7c933fe7b48 Mon Sep 17 00:00:00 2001 From: CloudKeeper1 Date: Sat, 22 Apr 2017 16:01:32 +1000 Subject: [PATCH] Extended get_input to accept *args & **kwargs Calling get_input with args and kwargs passes them to the callback function. Does not affect previous use so no changed required to existing code. --- evennia/utils/evmenu.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/evennia/utils/evmenu.py b/evennia/utils/evmenu.py index a59855716d..bd00b75788 100644 --- a/evennia/utils/evmenu.py +++ b/evennia/utils/evmenu.py @@ -894,9 +894,11 @@ class CmdGetInput(Command): caller.ndb._getinput._session = self.session prompt = caller.ndb._getinput._prompt + args = caller.ndb._getinput._args + kwargs = caller.ndb._getinput._kwargs 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, *args, **kwargs) if ok: # only clear the state if the callback does not return # anything @@ -930,7 +932,7 @@ class _Prompt(object): pass -def get_input(caller, prompt, callback, session=None): +def get_input(caller, prompt, callback, session=None, *args, **kwargs): """ This is a helper function for easily request input from the caller. @@ -981,6 +983,8 @@ def get_input(caller, prompt, callback, session=None): caller.ndb._getinput._callback = callback caller.ndb._getinput._prompt = prompt caller.ndb._getinput._session = session + caller.ndb._getinput._args = args + caller.ndb._getinput._kwargs = kwargs caller.cmdset.add(InputCmdSet) caller.msg(prompt, session=session)