+ for portal in sorted(
+ actor.universe.contents[actor.get("location")].portals()):
+ if portal.startswith(parameters):
+ actor.move_direction(portal)
+ return(portal)
+ actor.send("You cannot go that way.")
+ return True
+
+
+def preferences(actor, parameters):
+ """List, view and change actor preferences."""
+
+ # Escape replacement macros in preferences
+ parameters = mudpy.misc.escape_macros(parameters)
+
+ message = ""
+ arguments = parameters.split()
+ allowed_prefs = set()
+ base_prefs = []
+ user_config = actor.universe.contents.get("mudpy.user")
+ if user_config:
+ base_prefs = user_config.get("pref_allow", [])
+ allowed_prefs.update(base_prefs)
+ if actor.owner.account.get("administrator"):
+ allowed_prefs.update(user_config.get("pref_admin", []))
+ if not arguments:
+ message += "These are your current preferences:"
+
+ # color-code base and admin prefs
+ for pref in sorted(allowed_prefs):
+ if pref in base_prefs:
+ color = "grn"
+ else:
+ color = "red"
+ message += ("$(eol) $(%s)%s$(nrm) - %s" % (
+ color, pref, actor.owner.account.get(pref, "<not set>")))
+
+ elif arguments[0] not in allowed_prefs:
+ message += (
+ 'Preference "%s" does not exist. Try the `preferences` command by '
+ "itself for a list of valid preferences." % arguments[0])
+ elif len(arguments) == 1:
+ message += "%s" % actor.owner.account.get(arguments[0], "<not set>")