[control]
read_only = yes
+[menu:activate_avatar]
+action = user.avatar = universe.contents[user.account.getlist("avatars")[int(choice)-1]]
+action_a = pass
+branch = active
+branch_a = main_utility
+choice_a = abort selection
+create = dict([(str(x+1),y) for x,y in enumerate(user.list_avatar_names())])
+description = This is the list of avatars available for you to awaken.
+prompt = Whom would you like to awaken?
+
[menu:active]
prompt = >
description = Your new avatar needs a name. This will be the name with which $(tpsp) grew up, and will initially be the name by which $(tpsp) is known in the world of Example. There are ways for your new avatar to make a name for $(tpop)self over time, so $(tpsp) won't be stuck going by such an unremarkable name forever.
prompt = Choose a name for $(tpop):
+[menu:delete_avatar]
+action = user.delete_avatar(user.account.getlist("avatars")[int(choice)-1], universe)
+action_a = pass
+branch = main_utility
+branch_a = main_utility
+choice_a = abort selection
+create = dict([(str(x+1),y) for x,y in enumerate(user.list_avatar_names())])
+description = This is the list of avatars available for you to awaken.
+prompt = Whom would you like to awaken?
+
[menu:disconnecting]
description = $(red)Disconnecting...$(nrm)
[menu:main_utility]
action_c = user.new_avatar()
-branch_a = active
+branch_a = activate_avatar
branch_c = choose_gender
branch_d = delete_avatar
branch_l = disconnecting
branch_p = delete_account
-choice_a = activate an existing avatar
+choice_a = awaken an existing avatar
choice_c = create a new avatar
choice_d = delete an unwanted avatar
choice_l = leave example for now
demand_a = user.account.get("avatars")
demand_c = len(user.account.getlist("avatars")) < universe.categories["internal"]["limits"].getint("max_avatars")
demand_d = user.account.get("avatars")
-description = From here you can activate, create and delete avatars. An avatar is your persona in the world of Example.
-error_no_avatars = You don't have any avatars yet. An avatar is your persona in the world of Example. It is recommended that you create one now.
+description = From here you can awaken, create and delete avatars. An avatar is your persona in the world of Example. You can also leave or permanently delete your account.
prompt = What would you like to do?
[menu:verifying_new_password]
else: return makedict(value)
def set(self, facet, value):
"""Set values."""
- if type(value) is long: value = repr(value).rstrip("L")
+ if type(value) is long: value = str(value)
elif not type(value) is str: value = repr(value)
universe.files[self.origin].data.set(self.key, facet, value)
def new_avatar(self):
"""Instantiate a new, unconfigured avatar for this user."""
counter = universe.categories["internal"]["counters"].getint("next_avatar")
- while "avatar:" + repr(counter + 1) in universe.categories["actor"].keys(): counter += 1
+ while "avatar:" + str(counter + 1) in universe.categories["actor"].keys(): counter += 1
universe.categories["internal"]["counters"].set("next_avatar", counter + 1)
- self.avatar = Element("actor:avatar:" + repr(counter), universe)
+ self.avatar = Element("actor:avatar:" + str(counter), universe)
avatars = self.account.getlist("avatars")
avatars.append(self.avatar.key)
self.account.set("avatars", avatars)
- def list_avatar_names(self):
- """A test function to list names of assigned avatars."""
+ def delete_avatar(self, avatar, universe):
+ """Remove an avatar from the world and from the user's list."""
+ if self.avatar is universe.contents[avatar]: self.avatar = None
+ universe.contents[avatar].delete()
avatars = self.account.getlist("avatars")
- avatar_names = []
- for avatar in avatars:
- avatar_names.append(universe.contents[avatar].get("name"))
- return avatar_names
+ avatars.remove(avatar)
+ self.account.set("avatars", avatars)
+
+ def list_avatar_names(self):
+ """List names of assigned avatars."""
+ return [ universe.contents[avatar].get("name") for avatar in self.account.getlist("avatars") ]
def makelist(value):
"""Turn string into list type."""
# update the log every now and then
if check_time("frequency_log"):
- log(repr(len(universe.userlist)) + " connection(s)")
+ log(str(len(universe.userlist)) + " connection(s)")
# periodically save everything
if check_time("frequency_save"):
def get_menu_choices(user):
"""Return a dict of choice:meaning."""
- choices = {}
+ menu = universe.categories["menu"][user.state]
+ create_choices = menu.get("create")
+ if create_choices: choices = eval(create_choices)
+ else: choices = {}
ignores = []
options = {}
creates = {}
- for facet in universe.categories["menu"][user.state].facets():
+ for facet in menu.facets():
if facet.startswith("demand_") and not eval(universe.categories["menu"][user.state].get(facet)):
ignores.append(facet.split("_", 2)[1])
- elif facet.startswith("choice_"):
- options[facet] = facet.split("_", 2)[1]
elif facet.startswith("create_"):
creates[facet] = facet.split("_", 2)[1]
- for facet in options.keys():
- if not options[facet] in ignores:
- choices[options[facet]] = universe.categories["menu"][user.state].get(facet)
+ elif facet.startswith("choice_"):
+ options[facet] = facet.split("_", 2)[1]
for facet in creates.keys():
if not creates[facet] in ignores:
- choices[creates[facet]] = eval(universe.categories["menu"][user.state].get(facet))
+ choices[creates[facet]] = eval(menu.get(facet))
+ for facet in options.keys():
+ if not options[facet] in ignores:
+ choices[options[facet]] = menu.get(facet)
return choices
def get_formatted_menu_choices(state, choices):
def command_quit(user, command="", parameters=""):
"""Quit the world."""
- user.state = "disconnecting"
+ user.state = "main_utility"
def command_help(user, command="", parameters=""):
"""List available commands and provide help for commands."""