mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 02:36:32 +01:00
Made Empty cmdsets have priority -100, also changed their key from "Empty" to _EMPTY_CMDSET to make it clearer this is a special name. See also discussion in Issue 447.
This commit is contained in:
parent
acbfa57240
commit
48bfc7e54a
3 changed files with 13 additions and 7 deletions
|
|
@ -200,7 +200,7 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
|||
|
||||
# weed out all non-found sets
|
||||
cmdsets = yield [cmdset for cmdset in cmdsets
|
||||
if cmdset and cmdset.key != "Empty"]
|
||||
if cmdset and cmdset.key != "_EMPTY_CMDSET"]
|
||||
# report cmdset errors to user (these should already have been logged)
|
||||
yield [report_to.msg(cmdset.errmessage) for cmdset in cmdsets
|
||||
if cmdset.key == "_CMDSET_ERROR"]
|
||||
|
|
@ -218,6 +218,7 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
|||
tempmergers = {}
|
||||
for cmdset in cmdsets:
|
||||
prio = cmdset.priority
|
||||
#print cmdset.key, prio
|
||||
if prio in tempmergers:
|
||||
# merge same-prio cmdset together separately
|
||||
tempmergers[prio] = yield cmdset + tempmergers[prio]
|
||||
|
|
|
|||
|
|
@ -78,6 +78,11 @@ class _ErrorCmdSet(CmdSet):
|
|||
key = "_CMDSET_ERROR"
|
||||
errmessage = "Error when loading cmdset."
|
||||
|
||||
class _EmptyCmdSet(CmdSet):
|
||||
"This cmdset represents an empty cmdset"
|
||||
key = "_EMPTY_CMDSET"
|
||||
priority = -100
|
||||
mergetype = "Union"
|
||||
|
||||
def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||
"""
|
||||
|
|
@ -166,7 +171,7 @@ class CmdSetHandler(object):
|
|||
# this holds the "merged" current command set
|
||||
self.current = None
|
||||
# this holds a history of CommandSets
|
||||
self.cmdset_stack = [CmdSet(cmdsetobj=self.obj, key="Empty")]
|
||||
self.cmdset_stack = [_EmptyCmdSet(cmdsetobj=self.obj)]
|
||||
# this tracks which mergetypes are actually in play in the stack
|
||||
self.mergetype_stack = ["Union"]
|
||||
|
||||
|
|
@ -244,7 +249,7 @@ class CmdSetHandler(object):
|
|||
self.cmdset_stack = []
|
||||
for pos, path in enumerate(storage):
|
||||
if pos == 0 and not path:
|
||||
self.cmdset_stack = [CmdSet(cmdsetobj=self.obj, key="Empty")]
|
||||
self.cmdset_stack = [EmptyCmdSet(cmdsetobj=self.obj)]
|
||||
elif path:
|
||||
cmdset = self._import_cmdset(path)
|
||||
if cmdset:
|
||||
|
|
@ -410,9 +415,9 @@ class CmdSetHandler(object):
|
|||
else:
|
||||
storage = [""]
|
||||
self.cmdset_storage = storage
|
||||
self.cmdset_stack[0] = CmdSet(cmdsetobj=self.obj, key="Empty")
|
||||
self.cmdset_stack[0] = EmptyCmdSet(cmdsetobj=self.obj)
|
||||
else:
|
||||
self.cmdset_stack = [CmdSet(cmdsetobj=self.obj, key="Empty")]
|
||||
self.cmdset_stack = [EmptyCmdSet(cmdsetobj=self.obj)]
|
||||
self.update()
|
||||
|
||||
def all(self):
|
||||
|
|
@ -453,7 +458,7 @@ class CmdSetHandler(object):
|
|||
new_cmdset_stack = []
|
||||
new_mergetype_stack = []
|
||||
for cmdset in self.cmdset_stack:
|
||||
if cmdset.key == "Empty":
|
||||
if cmdset.key == "_EMPTY_CMDSET":
|
||||
new_cmdset_stack.append(cmdset)
|
||||
new_mergetype_stack.append("Union")
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1685,7 +1685,7 @@ class CmdExamine(ObjManipCommand):
|
|||
|
||||
string += "\n{wLocks{n:%s" % locks_string
|
||||
|
||||
if not (len(obj.cmdset.all()) == 1 and obj.cmdset.current.key == "Empty"):
|
||||
if not (len(obj.cmdset.all()) == 1 and obj.cmdset.current.key == "_EMPTY_CMDSET"):
|
||||
# list the current cmdsets
|
||||
all_cmdsets = (obj.cmdset.all() +
|
||||
(hasattr(obj, "player") and obj.player and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue