mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 21:17:17 +02:00
Added state persistence to commands. For commands that want to, their state will be saved for the next command to access through the self.caller.ndb.last_cmd variable. The state only persists one command before it is cleared or replaced.
This commit is contained in:
parent
a6f3e1f47f
commit
6e53e6a1fd
4 changed files with 14 additions and 3 deletions
|
|
@ -35,6 +35,7 @@ command line. The process is as follows:
|
|||
|
||||
"""
|
||||
|
||||
from copy import copy
|
||||
from traceback import format_exc
|
||||
from django.conf import settings
|
||||
from src.comms.channelhandler import CHANNELHANDLER
|
||||
|
|
@ -225,7 +226,7 @@ def cmdhandler(caller, raw_string, testing=False):
|
|||
if testing:
|
||||
# only return the command instance
|
||||
return cmd
|
||||
|
||||
|
||||
# pre-command hook
|
||||
cmd.at_pre_cmd()
|
||||
|
||||
|
|
@ -236,6 +237,14 @@ def cmdhandler(caller, raw_string, testing=False):
|
|||
|
||||
# post-command hook
|
||||
cmd.at_post_cmd()
|
||||
|
||||
if cmd.save_next:
|
||||
# store a reference to this command, possibly
|
||||
# accessible by the next command.
|
||||
caller.ndb.last_cmd = copy(cmd)
|
||||
else:
|
||||
caller.ndb.last_cmd = None
|
||||
|
||||
# Done! By default, Evennia does not use this return at all
|
||||
return ret
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue