mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 12:37:16 +02:00
Added **kwargs to cmdhandler and execute_cmd() methods, to set arbitrary flags on commands at run-time. Unused by default Evennia but may be useful to codedly change operation parameters on commands at run-time.
This commit is contained in:
parent
19d6d4ff9e
commit
a88afabd60
5 changed files with 33 additions and 8 deletions
|
|
@ -251,7 +251,7 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
|||
# Main command-handler function
|
||||
|
||||
@inlineCallbacks
|
||||
def cmdhandler(called_by, raw_string, testing=False, callertype="session", sessid=None):
|
||||
def cmdhandler(called_by, raw_string, testing=False, callertype="session", sessid=None, **kwargs):
|
||||
"""
|
||||
This is the main function to handle any string sent to the engine.
|
||||
|
||||
|
|
@ -268,6 +268,10 @@ def cmdhandler(called_by, raw_string, testing=False, callertype="session", sessi
|
|||
giving them precendence for same-name and same-prio commands.
|
||||
sessid - Relevant if callertype is "player" - the session id will help
|
||||
retrieve the correct cmdsets from puppeted objects.
|
||||
**kwargs - other keyword arguments will be assigned as named variables on the
|
||||
retrieved command object *before* it is executed. This is unuesed
|
||||
in default Evennia but may be used by code to set custom flags or
|
||||
special operating conditions for a command as it executes.
|
||||
|
||||
Note that this function returns a deferred!
|
||||
"""
|
||||
|
|
@ -392,6 +396,10 @@ def cmdhandler(called_by, raw_string, testing=False, callertype="session", sessi
|
|||
# only return the command instance
|
||||
returnValue(cmd)
|
||||
|
||||
# assign custom kwargs to found cmd object
|
||||
for key, val in kwargs.items():
|
||||
setattr(cmd, key, val)
|
||||
|
||||
# pre-command hook
|
||||
yield cmd.at_pre_cmd()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue