mirror of
https://github.com/evennia/evennia.git
synced 2026-03-22 15:56:30 +01:00
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
|
||||
|
||||
if not aliases:
|
||||
caller.msg("Usage: @alias <obj> = <alias>")
|
||||
caller.msg("Usage: @alias <obj> = <alias>,<alias>,...")
|
||||
return
|
||||
# Find the object to receive aliases
|
||||
obj = caller.search(objname, global_search=True)
|
||||
|
|
@ -195,17 +195,15 @@ class CmdSetObjAlias(MuxCommand):
|
|||
caller.msg("You don't have permission to do that.")
|
||||
return
|
||||
# merge the old and new aliases (if any)
|
||||
old_aliases = obj.aliases.split(',')
|
||||
old_aliases = obj.aliases
|
||||
new_aliases = [str(alias).strip().lower()
|
||||
for alias in aliases if alias.strip()]
|
||||
# make the aliases only appear once
|
||||
old_aliases.extend(new_aliases)
|
||||
aliases = list(set(old_aliases))
|
||||
aliases = ",".join(str(alias).lower().strip() for alias in aliases if alias)
|
||||
aliases = list(set(old_aliases))
|
||||
# save back to object.
|
||||
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):
|
||||
|
|
@ -1465,19 +1463,21 @@ class CmdExamine(ObjManipCommand):
|
|||
|
||||
returns a string.
|
||||
"""
|
||||
dbref = ""
|
||||
if has_perm_string(self.caller, 'see_dbref'):
|
||||
dbref = "(#%i)" % obj.id
|
||||
string = "\n{wName{n: %s%s" % (obj.name, dbref)
|
||||
|
||||
string = "\n{wName/key{n: %s (#%i)" % (obj.name, obj.id)
|
||||
if obj.aliases:
|
||||
string += "\n{wAliases{n: %s" % (", ".join(obj.aliases))
|
||||
if obj.has_player:
|
||||
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
|
||||
perms = obj.permissions
|
||||
if obj.player and obj.player.is_superuser:
|
||||
perms = "<Superuser>"
|
||||
string += "\n{wPerms/Locks{n: %s" % utils.fill(perms)
|
||||
if obj.cmdset.all():
|
||||
perms = ["<Superuser>"]
|
||||
elif not perms:
|
||||
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
|
||||
if obj.scripts.all():
|
||||
string += "\n{wScripts{n:\n\r %s" % obj.scripts
|
||||
|
|
|
|||
|
|
@ -33,12 +33,33 @@ class CmdReload(MuxCommand):
|
|||
|
||||
def func(self):
|
||||
"""
|
||||
reload the system.
|
||||
Reload the system.
|
||||
"""
|
||||
caller = self.caller
|
||||
reloads.reload_modules()
|
||||
reloads.reload_scripts()
|
||||
reloads.reload_commands()
|
||||
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_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):
|
||||
"""
|
||||
|
|
@ -607,12 +628,14 @@ class CmdPerm(MuxCommand):
|
|||
return
|
||||
else:
|
||||
#just print all available permissions
|
||||
string = "\nAll currently available permissions (i.e. not locks):"
|
||||
pgroups = PermissionGroup.objects.all()
|
||||
string = "\nAll defined permission groups and keys (i.e. not locks):"
|
||||
pgroups = list(PermissionGroup.objects.all())
|
||||
pgroups.sort(lambda x,y: cmp(x.key, y.key)) # sort by group key
|
||||
|
||||
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" % \
|
||||
utils.fill(", ".join(pgroup.group_permissions))
|
||||
utils.fill(", ".join(sorted(pgroup.group_permissions)))
|
||||
caller.msg(string)
|
||||
return
|
||||
|
||||
|
|
@ -622,13 +645,16 @@ class CmdPerm(MuxCommand):
|
|||
return
|
||||
|
||||
if not rhs:
|
||||
#if we didn't have any =, we list the permissions set on <object>.
|
||||
if hasattr(obj, 'is_superuser') and obj.is_superuser:
|
||||
string = "\n This is a SUPERUSER account! "
|
||||
string += "All permissions are automatically set."
|
||||
string = "Permission string on {w%s{n: " % obj.key
|
||||
if not obj.permissions:
|
||||
string += "<None>"
|
||||
else:
|
||||
string = "Permissions set on this object:\n"
|
||||
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)
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -327,9 +327,7 @@ class Character(Object):
|
|||
def at_after_move(self, source_location):
|
||||
"Default is to look around after a move."
|
||||
self.execute_cmd('look')
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Base Room object
|
||||
#
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import datetime
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from src.typeclasses.managers import returns_typeclass_list, returns_typeclass
|
||||
from src.utils import logger
|
||||
|
||||
#
|
||||
# Player Manager
|
||||
|
|
@ -32,7 +33,7 @@ def returns_player_list(method):
|
|||
try:
|
||||
players.append(user.get_profile())
|
||||
except Exception:
|
||||
players.append(user)
|
||||
logger.log_trace("User has no profile(), maybe database was partially reset?")
|
||||
return players
|
||||
return func
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ def create_objects():
|
|||
|
||||
# Limbo is the initial starting room.
|
||||
|
||||
object_typeclass = settings.BASE_OBJECT_TYPECLASS
|
||||
limbo_obj = create.create_object(object_typeclass, 'Limbo')
|
||||
room_typeclass = settings.BASE_ROOM_TYPECLASS
|
||||
limbo_obj = create.create_object(room_typeclass, 'Limbo')
|
||||
limbo_obj.id = 2
|
||||
string = "Welcome to your new %chEvennia%cn-based game."
|
||||
string += " From here you are ready to begin development."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue