Included 'Alias' field for examine (issue98). Fixed a rare traceback with @reload in situations when it tried to move on before modules has time to finish reloading. Also clarified how @perm and examine display information.
This commit is contained in:
parent
e2f92f0bfe
commit
ec5295b973
5 changed files with 58 additions and 33 deletions
|
|
@ -184,7 +184,7 @@ class CmdSetObjAlias(MuxCommand):
|
||||||
objname, aliases = self.lhs, self.rhslist
|
objname, aliases = self.lhs, self.rhslist
|
||||||
|
|
||||||
if not aliases:
|
if not aliases:
|
||||||
caller.msg("Usage: @alias <obj> = <alias>")
|
caller.msg("Usage: @alias <obj> = <alias>,<alias>,...")
|
||||||
return
|
return
|
||||||
# Find the object to receive aliases
|
# Find the object to receive aliases
|
||||||
obj = caller.search(objname, global_search=True)
|
obj = caller.search(objname, global_search=True)
|
||||||
|
|
@ -195,17 +195,15 @@ class CmdSetObjAlias(MuxCommand):
|
||||||
caller.msg("You don't have permission to do that.")
|
caller.msg("You don't have permission to do that.")
|
||||||
return
|
return
|
||||||
# merge the old and new aliases (if any)
|
# merge the old and new aliases (if any)
|
||||||
old_aliases = obj.aliases.split(',')
|
old_aliases = obj.aliases
|
||||||
new_aliases = [str(alias).strip().lower()
|
new_aliases = [str(alias).strip().lower()
|
||||||
for alias in aliases if alias.strip()]
|
for alias in aliases if alias.strip()]
|
||||||
# make the aliases only appear once
|
# make the aliases only appear once
|
||||||
old_aliases.extend(new_aliases)
|
old_aliases.extend(new_aliases)
|
||||||
aliases = list(set(old_aliases))
|
aliases = list(set(old_aliases))
|
||||||
aliases = ",".join(str(alias).lower().strip() for alias in aliases if alias)
|
|
||||||
# save back to object.
|
# save back to object.
|
||||||
obj.aliases = aliases
|
obj.aliases = aliases
|
||||||
obj.save()
|
caller.msg("Aliases for '%s' are now set to %s." % (obj.name, aliases))
|
||||||
caller.msg("Aliases for '%s' are now set to [%s]." % (obj.name, aliases))
|
|
||||||
|
|
||||||
|
|
||||||
class CmdName(ObjManipCommand):
|
class CmdName(ObjManipCommand):
|
||||||
|
|
@ -1465,19 +1463,21 @@ class CmdExamine(ObjManipCommand):
|
||||||
|
|
||||||
returns a string.
|
returns a string.
|
||||||
"""
|
"""
|
||||||
dbref = ""
|
|
||||||
if has_perm_string(self.caller, 'see_dbref'):
|
string = "\n{wName/key{n: %s (#%i)" % (obj.name, obj.id)
|
||||||
dbref = "(#%i)" % obj.id
|
if obj.aliases:
|
||||||
string = "\n{wName{n: %s%s" % (obj.name, dbref)
|
string += "\n{wAliases{n: %s" % (", ".join(obj.aliases))
|
||||||
if obj.has_player:
|
if obj.has_player:
|
||||||
string += "\n{wPlayer{n: %s" % obj.player.name
|
string += "\n{wPlayer{n: %s" % obj.player.name
|
||||||
string += "\n{wTypeclass{n: %s" % utils.fill(obj.typeclass)
|
string += "\n{wTypeclass{n: %s (%s)" % (obj.typeclass, obj.typeclass_path)
|
||||||
string += "\n{wLocation{n: %s" % obj.location
|
string += "\n{wLocation{n: %s" % obj.location
|
||||||
perms = obj.permissions
|
perms = obj.permissions
|
||||||
if obj.player and obj.player.is_superuser:
|
if obj.player and obj.player.is_superuser:
|
||||||
perms = "<Superuser>"
|
perms = ["<Superuser>"]
|
||||||
string += "\n{wPerms/Locks{n: %s" % utils.fill(perms)
|
elif not perms:
|
||||||
if obj.cmdset.all():
|
perms = ["<None>"]
|
||||||
|
string += "\n{wPerms/Locks{n: %s" % (", ".join(perms))
|
||||||
|
if not (len(obj.cmdset.all()) == 1 and obj.cmdset.current.key == "Empty"):
|
||||||
string += "\n{wCurrent Cmdset{n:\n\r %s" % obj.cmdset
|
string += "\n{wCurrent Cmdset{n:\n\r %s" % obj.cmdset
|
||||||
if obj.scripts.all():
|
if obj.scripts.all():
|
||||||
string += "\n{wScripts{n:\n\r %s" % obj.scripts
|
string += "\n{wScripts{n:\n\r %s" % obj.scripts
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,33 @@ class CmdReload(MuxCommand):
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"""
|
"""
|
||||||
reload the system.
|
Reload the system.
|
||||||
"""
|
"""
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
reloads.reload_modules()
|
reloads.reload_modules()
|
||||||
|
|
||||||
|
max_attempts = 4
|
||||||
|
for attempt in range(max_attempts):
|
||||||
|
# if reload modules take a long time,
|
||||||
|
# we might end up in a situation where
|
||||||
|
# the subsequent commands fail since they
|
||||||
|
# can't find the reloads module (due to it
|
||||||
|
# not yet fully loaded). So we retry a few
|
||||||
|
# times before giving up.
|
||||||
|
try:
|
||||||
reloads.reload_scripts()
|
reloads.reload_scripts()
|
||||||
reloads.reload_commands()
|
reloads.reload_commands()
|
||||||
|
break
|
||||||
|
except AttributeError:
|
||||||
|
if attempt < max_attempts-1:
|
||||||
|
caller.msg(" Waiting for modules(s) to finish (%s) ..." % attempt)
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
string = " ... The module(s) took too long to reload, "
|
||||||
|
string += "\n so the remainding reloads where skipped."
|
||||||
|
string += "\n Re-run @reload again when modules have fully "
|
||||||
|
string += "\n re-initialized."
|
||||||
|
caller.msg(string)
|
||||||
|
|
||||||
class CmdPy(MuxCommand):
|
class CmdPy(MuxCommand):
|
||||||
"""
|
"""
|
||||||
|
|
@ -607,12 +628,14 @@ class CmdPerm(MuxCommand):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
#just print all available permissions
|
#just print all available permissions
|
||||||
string = "\nAll currently available permissions (i.e. not locks):"
|
string = "\nAll defined permission groups and keys (i.e. not locks):"
|
||||||
pgroups = PermissionGroup.objects.all()
|
pgroups = list(PermissionGroup.objects.all())
|
||||||
|
pgroups.sort(lambda x,y: cmp(x.key, y.key)) # sort by group key
|
||||||
|
|
||||||
for pgroup in pgroups:
|
for pgroup in pgroups:
|
||||||
string += "\n\n - %s (%s):" % (pgroup.key, pgroup.desc)
|
string += "\n\n - {w%s{n (%s):" % (pgroup.key, pgroup.desc)
|
||||||
string += "\n%s" % \
|
string += "\n%s" % \
|
||||||
utils.fill(", ".join(pgroup.group_permissions))
|
utils.fill(", ".join(sorted(pgroup.group_permissions)))
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -622,13 +645,16 @@ class CmdPerm(MuxCommand):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not rhs:
|
if not rhs:
|
||||||
#if we didn't have any =, we list the permissions set on <object>.
|
string = "Permission string on {w%s{n: " % obj.key
|
||||||
if hasattr(obj, 'is_superuser') and obj.is_superuser:
|
if not obj.permissions:
|
||||||
string = "\n This is a SUPERUSER account! "
|
string += "<None>"
|
||||||
string += "All permissions are automatically set."
|
|
||||||
else:
|
else:
|
||||||
string = "Permissions set on this object:\n"
|
|
||||||
string += ", ".join(obj.permissions)
|
string += ", ".join(obj.permissions)
|
||||||
|
if obj.player and obj.player.is_superuser:
|
||||||
|
string += "\n(... But this object's player is a SUPERUSER! "
|
||||||
|
string += "All access checked are passed automatically.)"
|
||||||
|
|
||||||
|
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -328,8 +328,6 @@ class Character(Object):
|
||||||
"Default is to look around after a move."
|
"Default is to look around after a move."
|
||||||
self.execute_cmd('look')
|
self.execute_cmd('look')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Base Room object
|
# Base Room object
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import datetime
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from src.typeclasses.managers import returns_typeclass_list, returns_typeclass
|
from src.typeclasses.managers import returns_typeclass_list, returns_typeclass
|
||||||
|
from src.utils import logger
|
||||||
|
|
||||||
#
|
#
|
||||||
# Player Manager
|
# Player Manager
|
||||||
|
|
@ -32,7 +33,7 @@ def returns_player_list(method):
|
||||||
try:
|
try:
|
||||||
players.append(user.get_profile())
|
players.append(user.get_profile())
|
||||||
except Exception:
|
except Exception:
|
||||||
players.append(user)
|
logger.log_trace("User has no profile(), maybe database was partially reset?")
|
||||||
return players
|
return players
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ def create_objects():
|
||||||
|
|
||||||
# Limbo is the initial starting room.
|
# Limbo is the initial starting room.
|
||||||
|
|
||||||
object_typeclass = settings.BASE_OBJECT_TYPECLASS
|
room_typeclass = settings.BASE_ROOM_TYPECLASS
|
||||||
limbo_obj = create.create_object(object_typeclass, 'Limbo')
|
limbo_obj = create.create_object(room_typeclass, 'Limbo')
|
||||||
limbo_obj.id = 2
|
limbo_obj.id = 2
|
||||||
string = "Welcome to your new %chEvennia%cn-based game."
|
string = "Welcome to your new %chEvennia%cn-based game."
|
||||||
string += " From here you are ready to begin development."
|
string += " From here you are ready to begin development."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue