Create fallback for default cmdsets that fail to load
This commit is contained in:
parent
24c5ddecab
commit
bafd069d97
2 changed files with 14 additions and 0 deletions
|
|
@ -351,6 +351,14 @@ class CmdSetHandler(object):
|
||||||
elif path:
|
elif path:
|
||||||
cmdset = self._import_cmdset(path)
|
cmdset = self._import_cmdset(path)
|
||||||
if cmdset:
|
if cmdset:
|
||||||
|
if cmdset.key == '_CMDSET_ERROR':
|
||||||
|
# If a cmdset fails to load, check if we have a fallback path to use
|
||||||
|
fallback_path = settings.CMDSET_FALLBACKS.get(path, None)
|
||||||
|
if fallback_path:
|
||||||
|
cmdset = self._import_cmdset(fallback_path)
|
||||||
|
# If no cmdset is returned from the fallback, we can't go further
|
||||||
|
if not cmdset:
|
||||||
|
continue
|
||||||
cmdset.permanent = cmdset.key != '_CMDSET_ERROR'
|
cmdset.permanent = cmdset.key != '_CMDSET_ERROR'
|
||||||
self.cmdset_stack.append(cmdset)
|
self.cmdset_stack.append(cmdset)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -348,6 +348,12 @@ CMDSET_CHARACTER = "commands.default_cmdsets.CharacterCmdSet"
|
||||||
CMDSET_PLAYER = "commands.default_cmdsets.PlayerCmdSet"
|
CMDSET_PLAYER = "commands.default_cmdsets.PlayerCmdSet"
|
||||||
# Location to search for cmdsets if full path not given
|
# Location to search for cmdsets if full path not given
|
||||||
CMDSET_PATHS = ["commands", "evennia", "contribs"]
|
CMDSET_PATHS = ["commands", "evennia", "contribs"]
|
||||||
|
# Fallbacks for cmdset paths that fail to load. Note that if you change the path for your default cmdsets,
|
||||||
|
# you will also need to copy CMDSET_FALLBACKS after your change in your settings file for it to detect the change.
|
||||||
|
CMDSET_FALLBACKS = {CMDSET_CHARACTER: 'evennia.commands.default.cmdset_character.CharacterCmdSet',
|
||||||
|
CMDSET_PLAYER: 'evennia.commands.default.cmdset_player.PlayerCmdSet',
|
||||||
|
CMDSET_SESSION: 'evennia.commands.default.cmdset_session.SessionCmdSet',
|
||||||
|
CMDSET_UNLOGGEDIN: 'evennia.commands.default.cmdset_unloggedin.UnloggedinCmdSet'}
|
||||||
# Parent class for all default commands. Changing this class will
|
# Parent class for all default commands. Changing this class will
|
||||||
# modify all default commands, so do so carefully.
|
# modify all default commands, so do so carefully.
|
||||||
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"
|
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue