Made so the default add_default_cmdset script also removes the added cmdset when stopped. Fixed the function of @delplayer command.

This commit is contained in:
Griatch 2010-09-05 18:20:39 +00:00
parent 212061abb6
commit e125763ea5
5 changed files with 86 additions and 36 deletions

View file

@ -307,7 +307,7 @@ class CmdSetHandler(object):
the last cmdset in the stack is removed. Whenever
the cmdset_stack changes, the cmdset is updated.
The default cmdset (first entry in stack) is never
removed - set it to an empty set with add_default instead.
removed - remove it explicitly with delete_default.
key_or_class - a specific cmdset key or a cmdset class (in
the latter case, *all* cmdsets of this class
@ -339,6 +339,11 @@ class CmdSetHandler(object):
# re-sync the cmdsethandler.
self.update()
def delete_default(self):
"This explicitly deletes the default cmdset. It's the only command that can."
self.cmdset_stack[0] = CmdSet(cmdsetobj=self.obj, key="Empty")
self.update()
def all(self):
"""
Returns the list of cmdsets. Mostly useful to check if stack if empty or not.

View file

@ -301,3 +301,13 @@ class AddCmdSet(Script):
else:
self.obj.cmdset.add(cmdset)
def at_stop(self):
"""
This removes the cmdset when the script stops
"""
cmdset = self.db.cmdset
if cmdset:
if self.db.add_default:
self.obj.cmdset.delete_default()
else:
self.obj.cmdset.delete(cmdset)

View file

@ -417,7 +417,7 @@ def create_player(name, email, password,
new_user = User.objects.create_user(name, email, password)
# create the associated Player for this User, and tie them together
new_player = PlayerDB(user=new_user)
new_player = PlayerDB(db_key=name, user=new_user)
new_player.save()
# assign mud permissions