Made irc bot connect, but scripthandler lookup is causing traceback when searching for a player)

This commit is contained in:
Griatch 2014-02-24 00:37:32 +01:00
parent 8b52591c2f
commit 6c45d76b56
11 changed files with 70 additions and 37 deletions

View file

@ -44,13 +44,22 @@ class ScriptManager(TypedObjectManager):
if not obj:
return []
obj = obj.dbobj
player = obj.__class__.__name__ == "PlayerDB"
print "get_all_scripts_on_obj:", obj, player
if key:
dbref = self.dbref(key)
if dbref or dbref == 0:
script = self.filter(db_obj=obj, id=dbref)
if player:
script = self.filter(db_player=obj, id=dbref)
else:
script = self.filter(db_obj=obj, id=dbref)
if script:
return script
elif player:
return self.filter(db_player=obj, db_key=key)
return self.filter(db_obj=obj.dbobj, db_key=key)
if player:
self.filter(db_player=obj)
return self.filter(db_obj=obj)
@returns_typeclass_list

View file

@ -58,7 +58,13 @@ class ScriptHandler(object):
definition)
autostart - start the script upon adding it
"""
script = create.create_script(scriptclass, key=key, obj=self.obj,
if self.obj.dbobj.__class__.__name__ == "PlayerDB":
# we add to a Player, not an Object
script = create.create_script(scriptclass, key=key, player=self.obj,
autostart=autostart)
else:
# the normal - adding to an Object
script = create.create_script(scriptclass, key=key, obj=self.obj,
autostart=autostart)
if not script:
logger.log_errmsg("Script %s could not be created and/or started." % scriptclass)
@ -75,12 +81,13 @@ class ScriptHandler(object):
num += script.start()
return num
def delete(self, scriptid):
def delete(self, scriptid=None):
"""
Forcibly delete a script from this object.
scriptid can be a script key or the path to a script (in the
latter case all scripts with this path will be deleted!)
If no scriptid is set, delete all scripts on the object.
"""
delscripts = ScriptDB.objects.get_all_scripts_on_obj(self.obj, key=scriptid)
@ -91,7 +98,7 @@ class ScriptHandler(object):
num += script.stop()
return num
def stop(self, scriptid):
def stop(self, scriptid=None):
"""
Alias for delete. scriptid can be a script key or a script path string.
"""