mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 13:07:16 +02:00
Added the ability for the Command.func() method to return a value. This allows to potentially do e.g. value = caller.execute_cmd('cmdname'). Not used at all by default commands nor the engine itself, but potentially useful for admins wanting to implement some sort of 'nested' command structure, maybe using a custom input language.
This commit is contained in:
parent
7195e1e773
commit
e7b46c89b4
2 changed files with 10 additions and 3 deletions
|
|
@ -234,11 +234,13 @@ def cmdhandler(caller, raw_string, unloggedin=False, testing=False):
|
|||
|
||||
# Parse and execute
|
||||
cmd.parse()
|
||||
cmd.func()
|
||||
# (return value is normally None)
|
||||
ret = cmd.func()
|
||||
|
||||
# post-command hook
|
||||
cmd.at_post_cmd()
|
||||
# Done!
|
||||
# Done! By default, Evennia does not use this return at all
|
||||
return ret
|
||||
|
||||
except ExecSystemCommand, exc:
|
||||
# Not a normal command: run a system command, if available,
|
||||
|
|
|
|||
|
|
@ -556,6 +556,11 @@ class ObjectDB(TypedObject):
|
|||
Do something as this object. This command transparently
|
||||
lets its typeclass execute the command.
|
||||
raw_string - raw command input coming from the command line.
|
||||
|
||||
The return from this method is None for all default commands
|
||||
(it's the return value of cmd.func()) and is not used in any
|
||||
way by the engine. It might be useful for admins wanting to
|
||||
implement some sort of 'nested' command structure though,
|
||||
"""
|
||||
# nick replacement - we require full-word matching.
|
||||
|
||||
|
|
@ -568,7 +573,7 @@ class ObjectDB(TypedObject):
|
|||
if nick.db_nick in raw_list:
|
||||
raw_string = raw_string.replace(nick.db_nick, nick.db_real, 1)
|
||||
break
|
||||
cmdhandler.cmdhandler(self.typeclass, raw_string)
|
||||
return cmdhandler.cmdhandler(self.typeclass, raw_string)
|
||||
|
||||
def msg(self, message, from_obj=None, data=None):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue