Bugfixes.
This commit is contained in:
parent
b25fb14811
commit
8ea87f4727
1 changed files with 37 additions and 26 deletions
|
|
@ -21,6 +21,7 @@ from evennia.scripts.scripthandler import ScriptHandler
|
||||||
from evennia.commands import cmdset, command
|
from evennia.commands import cmdset, command
|
||||||
from evennia.commands.cmdsethandler import CmdSetHandler
|
from evennia.commands.cmdsethandler import CmdSetHandler
|
||||||
from evennia.commands import cmdhandler
|
from evennia.commands import cmdhandler
|
||||||
|
from evennia.utils import create
|
||||||
from evennia.utils import search
|
from evennia.utils import search
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
from evennia.utils import ansi
|
from evennia.utils import ansi
|
||||||
|
|
@ -429,7 +430,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
# only allow exact matching if searching the entire database
|
# only allow exact matching if searching the entire database
|
||||||
# or unique #dbrefs
|
# or unique #dbrefs
|
||||||
exact = True
|
exact = True
|
||||||
elif candidates is None:
|
else:
|
||||||
|
# TODO: write code...if candidates is None:
|
||||||
# no custom candidates given - get them automatically
|
# no custom candidates given - get them automatically
|
||||||
if location:
|
if location:
|
||||||
# location(s) were given
|
# location(s) were given
|
||||||
|
|
@ -872,7 +874,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
key (str): Name of the new object.
|
key (str): Name of the new object.
|
||||||
account (Account): Account to attribute this object to
|
account (Account): Account to attribute this object to.
|
||||||
|
|
||||||
Kwargs:
|
Kwargs:
|
||||||
description (str): Brief description for this object.
|
description (str): Brief description for this object.
|
||||||
|
|
@ -887,7 +889,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
obj = None
|
obj = None
|
||||||
|
|
||||||
# Get IP address of creator, if available
|
# Get IP address of creator, if available
|
||||||
ip = kwargs.pop('ip')
|
ip = kwargs.pop('ip', '')
|
||||||
|
|
||||||
# If no typeclass supplied, use this class
|
# If no typeclass supplied, use this class
|
||||||
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
||||||
|
|
@ -895,6 +897,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
# Set the supplied key as the name of the intended object
|
# Set the supplied key as the name of the intended object
|
||||||
kwargs['key'] = key
|
kwargs['key'] = key
|
||||||
|
|
||||||
|
# Get a supplied description, if any
|
||||||
|
description = kwargs.pop('description', '')
|
||||||
|
|
||||||
# Create a sane lockstring if one wasn't supplied
|
# Create a sane lockstring if one wasn't supplied
|
||||||
lockstring = kwargs.get('locks')
|
lockstring = kwargs.get('locks')
|
||||||
if account and not lockstring:
|
if account and not lockstring:
|
||||||
|
|
@ -907,16 +912,15 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
|
|
||||||
# Record creator id and creation IP
|
# Record creator id and creation IP
|
||||||
if ip: obj.db.creator_ip = ip
|
if ip: obj.db.creator_ip = ip
|
||||||
if caller: obj.db.creator_id = account.id
|
if account: obj.db.creator_id = account.id
|
||||||
|
|
||||||
# Set description if there is none, or update it if provided
|
# Set description if there is none, or update it if provided
|
||||||
if kwargs.get('description') or not obj.db.desc:
|
if description or not obj.db.desc:
|
||||||
desc = kwargs.get('description', "You see nothing special.")
|
desc = description if description else "You see nothing special."
|
||||||
obj.db.desc = desc
|
obj.db.desc = desc
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append("There was an error creating the Object '%s'. If this problem persists, contact an admin." % key)
|
errors.append(str(e))
|
||||||
logger.log_trace()
|
|
||||||
|
|
||||||
return obj, errors
|
return obj, errors
|
||||||
|
|
||||||
|
|
@ -1914,7 +1918,7 @@ class DefaultCharacter(DefaultObject):
|
||||||
obj = None
|
obj = None
|
||||||
|
|
||||||
# Get IP address of creator, if available
|
# Get IP address of creator, if available
|
||||||
ip = kwargs.pop('ip')
|
ip = kwargs.pop('ip', '')
|
||||||
|
|
||||||
# If no typeclass supplied, use this class
|
# If no typeclass supplied, use this class
|
||||||
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
||||||
|
|
@ -1928,6 +1932,12 @@ class DefaultCharacter(DefaultObject):
|
||||||
# Get permissions
|
# Get permissions
|
||||||
kwargs['permissions'] = kwargs.get('permissions', settings.PERMISSION_ACCOUNT_DEFAULT)
|
kwargs['permissions'] = kwargs.get('permissions', settings.PERMISSION_ACCOUNT_DEFAULT)
|
||||||
|
|
||||||
|
# Get description if provided
|
||||||
|
description = kwargs.pop('description', '')
|
||||||
|
|
||||||
|
# Get locks if provided
|
||||||
|
locks = kwargs.pop('locks', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Create the Character
|
# Create the Character
|
||||||
obj = create.create_object(**kwargs)
|
obj = create.create_object(**kwargs)
|
||||||
|
|
@ -1937,7 +1947,6 @@ class DefaultCharacter(DefaultObject):
|
||||||
if account: obj.db.creator_id = account.id
|
if account: obj.db.creator_id = account.id
|
||||||
|
|
||||||
# Add locks
|
# Add locks
|
||||||
locks = kwargs.pop('locks')
|
|
||||||
if not locks and account:
|
if not locks and account:
|
||||||
# Allow only the character itself and the creator account to puppet this character (and Developers).
|
# Allow only the character itself and the creator account to puppet this character (and Developers).
|
||||||
locks = cls.lockstring.format(**{'character_id': obj.id, 'account_id': account.id})
|
locks = cls.lockstring.format(**{'character_id': obj.id, 'account_id': account.id})
|
||||||
|
|
@ -1947,12 +1956,11 @@ class DefaultCharacter(DefaultObject):
|
||||||
obj.locks.add(locks)
|
obj.locks.add(locks)
|
||||||
|
|
||||||
# If no description is set, set a default description
|
# If no description is set, set a default description
|
||||||
if kwargs.get('description') or not obj.db.desc:
|
if description or not obj.db.desc:
|
||||||
obj.db.desc = kwargs.get('description', "This is a character.")
|
obj.db.desc = description if description else "This is a character."
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append("There was an error creating a Character. If this problem persists, contact an admin.")
|
errors.append(str(e))
|
||||||
logger.log_trace()
|
|
||||||
|
|
||||||
return obj, errors
|
return obj, errors
|
||||||
|
|
||||||
|
|
@ -2103,7 +2111,7 @@ class DefaultRoom(DefaultObject):
|
||||||
obj = None
|
obj = None
|
||||||
|
|
||||||
# Get IP address of creator, if available
|
# Get IP address of creator, if available
|
||||||
ip = kwargs.pop('ip')
|
ip = kwargs.pop('ip', '')
|
||||||
|
|
||||||
# If no typeclass supplied, use this class
|
# If no typeclass supplied, use this class
|
||||||
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
||||||
|
|
@ -2114,6 +2122,9 @@ class DefaultRoom(DefaultObject):
|
||||||
# Get who to send errors to
|
# Get who to send errors to
|
||||||
kwargs['report_to'] = kwargs.pop('report_to', account)
|
kwargs['report_to'] = kwargs.pop('report_to', account)
|
||||||
|
|
||||||
|
# Get description, if provided
|
||||||
|
description = kwargs.pop('description', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Create the Room
|
# Create the Room
|
||||||
obj = create.create_object(**kwargs)
|
obj = create.create_object(**kwargs)
|
||||||
|
|
@ -2127,12 +2138,11 @@ class DefaultRoom(DefaultObject):
|
||||||
if account: obj.db.creator_id = account.id
|
if account: obj.db.creator_id = account.id
|
||||||
|
|
||||||
# If no description is set, set a default description
|
# If no description is set, set a default description
|
||||||
if kwargs.get('description') or not obj.db.desc:
|
if description or not obj.db.desc:
|
||||||
obj.db.desc = kwargs.get('description', "This is a room.")
|
obj.db.desc = description if description else "This is a room."
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append("There was an error creating a Room. If this problem persists, contact an admin.")
|
errors.append(str(e))
|
||||||
logger.log_trace()
|
|
||||||
|
|
||||||
return obj, errors
|
return obj, errors
|
||||||
|
|
||||||
|
|
@ -2259,7 +2269,7 @@ class DefaultExit(DefaultObject):
|
||||||
# Command hooks
|
# Command hooks
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, key, source, dest, account, **kwargs):
|
def create(cls, key, account, source, dest, **kwargs):
|
||||||
"""
|
"""
|
||||||
Creates a basic Exit with default parameters, unless otherwise
|
Creates a basic Exit with default parameters, unless otherwise
|
||||||
specified or extended.
|
specified or extended.
|
||||||
|
|
@ -2269,9 +2279,9 @@ class DefaultExit(DefaultObject):
|
||||||
Args:
|
Args:
|
||||||
key (str): Name of the new Exit, as it should appear from the
|
key (str): Name of the new Exit, as it should appear from the
|
||||||
source room.
|
source room.
|
||||||
|
account (obj): Account to associate this Exit with.
|
||||||
source (Room): The room to create this exit in.
|
source (Room): The room to create this exit in.
|
||||||
dest (Room): The room to which this exit should go.
|
dest (Room): The room to which this exit should go.
|
||||||
account (obj): Account to associate this Exit with.
|
|
||||||
|
|
||||||
Kwargs:
|
Kwargs:
|
||||||
description (str): Brief description for this object.
|
description (str): Brief description for this object.
|
||||||
|
|
@ -2286,7 +2296,7 @@ class DefaultExit(DefaultObject):
|
||||||
obj = None
|
obj = None
|
||||||
|
|
||||||
# Get IP address of creator, if available
|
# Get IP address of creator, if available
|
||||||
ip = kwargs.pop('ip')
|
ip = kwargs.pop('ip', '')
|
||||||
|
|
||||||
# If no typeclass supplied, use this class
|
# If no typeclass supplied, use this class
|
||||||
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
kwargs['typeclass'] = kwargs.pop('typeclass', cls)
|
||||||
|
|
@ -2301,6 +2311,8 @@ class DefaultExit(DefaultObject):
|
||||||
kwargs['location'] = source
|
kwargs['location'] = source
|
||||||
kwargs['destination'] = dest
|
kwargs['destination'] = dest
|
||||||
|
|
||||||
|
description = kwargs.pop('description', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Create the Exit
|
# Create the Exit
|
||||||
obj = create.create_object(**kwargs)
|
obj = create.create_object(**kwargs)
|
||||||
|
|
@ -2314,12 +2326,11 @@ class DefaultExit(DefaultObject):
|
||||||
if account: obj.db.creator_id = account.id
|
if account: obj.db.creator_id = account.id
|
||||||
|
|
||||||
# If no description is set, set a default description
|
# If no description is set, set a default description
|
||||||
if kwargs.get('description') or not obj.db.desc:
|
if description or not obj.db.desc:
|
||||||
obj.db.desc = kwargs.get('description', "This is an exit.")
|
obj.db.desc = description if description else "This is an exit."
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append("There was an error creating an Exit. If this problem persists, contact an admin.")
|
errors.append(str(e))
|
||||||
logger.log_trace()
|
|
||||||
|
|
||||||
return obj, errors
|
return obj, errors
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue