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."""