class Element:
"""An element of the universe."""
- def __init__(self, key, universe, origin=""):
- """Default values for the in-memory element variables."""
+ def __init__(self, key, universe, filename=None):
+ """Set up a new element."""
+
+ # not owned by a user by default (used for avatars)
self.owner = None
+
+ # no contents in here by default
self.contents = {}
+
+ # an event queue for the element
+ self.events = {}
+
+ # keep track of our key name
self.key = key
+
+ # parse out appropriate category and subkey names, add to list
if self.key.find(":") > 0:
self.category, self.subkey = self.key.split(":", 1)
else:
self.category = "other"
self.subkey = self.key
- if not self.category in universe.categories: self.category = "other"
+ if not self.category in universe.categories:
+ self.category = "other"
+ self.subkey = self.key
universe.categories[self.category][self.subkey] = self
- self.origin = origin
- if not self.origin: self.origin = universe.default_origins[self.category]
- if not isabs(self.origin):
- self.origin = abspath(self.origin)
+
+ # get an appropriate filename for the origin
+ if not filename: filename = universe.default_origins[self.category]
+ if not isabs(filename): filename = abspath(filename)
+
+ # add the file if it doesn't exist yet
+ if not filename in universe.files: DataFile(filename, universe)
+
+ # record a pointer to the origin file
+ self.origin = universe.files[filename]
+
+ # add a data section to the origin if necessary
+ if not self.origin.data.has_section(self.key):
+ self.origin.data.add_section(self.key)
+
+ # add this element to the universe contents
universe.contents[self.key] = self
- if not self.origin in universe.files:
- DataFile(self.origin, universe)
- if not universe.files[self.origin].data.has_section(self.key):
- universe.files[self.origin].data.add_section(self.key)
+
def destroy(self):
"""Remove an element from the universe and destroy it."""
- log("Destroying: " + self.key + ".", 2)
- universe.files[self.origin].data.remove_section(self.key)
+ self.origin.data.remove_section(self.key)
del universe.categories[self.category][self.subkey]
del universe.contents[self.key]
del self
- def delete(self, facet):
- """Delete a facet from the element."""
- if universe.files[self.origin].data.has_option(self.key, facet):
- universe.files[self.origin].data.remove_option(self.key, facet)
def facets(self):
"""Return a list of non-inherited facets for this element."""
- if self.key in universe.files[self.origin].data.sections():
- return universe.files[self.origin].data.options(self.key)
+ if self.key in self.origin.data.sections():
+ return self.origin.data.options(self.key)
else: return []
def has_facet(self, facet):
"""Return whether the non-inherited facet exists."""
return facet in self.facets()
def remove_facet(self, facet):
"""Remove a facet from the element."""
- if self.has_facet(facet): universe.files[self.origin].data.remove_option(self.key, facet)
+ if self.has_facet(facet):
+ self.origin.data.remove_option(self.key, facet)
+ self.origin.modified = True
def ancestry(self):
"""Return a list of the element's inheritance lineage."""
if self.has_facet("inherit"):
def get(self, facet, default=None):
"""Retrieve values."""
if default is None: default = ""
- if universe.files[self.origin].data.has_option(self.key, facet):
- return universe.files[self.origin].data.get(self.key, facet)
+ if self.origin.data.has_option(self.key, facet):
+ return self.origin.data.get(self.key, facet)
elif self.has_facet("inherit"):
for ancestor in self.ancestry():
if universe.contents[ancestor].has_facet(facet):
def getboolean(self, facet, default=None):
"""Retrieve values as boolean type."""
if default is None: default=False
- if universe.files[self.origin].data.has_option(self.key, facet):
- return universe.files[self.origin].data.getboolean(self.key, facet)
+ if self.origin.data.has_option(self.key, facet):
+ return self.origin.data.getboolean(self.key, facet)
elif self.has_facet("inherit"):
for ancestor in self.ancestry():
if universe.contents[ancestor].has_facet(facet):
def getint(self, facet, default=None):
"""Return values as int/long type."""
if default is None: default = 0
- if universe.files[self.origin].data.has_option(self.key, facet):
- return universe.files[self.origin].data.getint(self.key, facet)
+ if self.origin.data.has_option(self.key, facet):
+ return self.origin.data.getint(self.key, facet)
elif self.has_facet("inherit"):
for ancestor in self.ancestry():
if universe.contents[ancestor].has_facet(facet):
def getfloat(self, facet, default=None):
"""Return values as float type."""
if default is None: default = 0.0
- if universe.files[self.origin].data.has_option(self.key, facet):
- return universe.files[self.origin].data.getfloat(self.key, facet)
+ if self.origin.data.has_option(self.key, facet):
+ return self.origin.data.getfloat(self.key, facet)
elif self.has_facet("inherit"):
for ancestor in self.ancestry():
if universe.contents[ancestor].has_facet(facet):
else: return default
def set(self, facet, value):
"""Set values."""
- 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)
+ if not self.has_facet(facet) or not self.get(facet) == value:
+ if type(value) is long: value = str(value)
+ elif not type(value) is str: value = repr(value)
+ self.origin.data.set(self.key, facet, value)
+ self.origin.modified = True
def append(self, facet, value):
"""Append value tp a list."""
if type(value) is long: value = str(value)
newlist = self.getlist(facet)
newlist.append(value)
self.set(facet, newlist)
+
+ def new_event(self, action, when=None):
+ """Create, attach and enqueue an event element."""
+
+ # if when isn't specified, that means now
+ if not when: when = universe.get_time()
+
+ # events are elements themselves
+ event = Element("event:" + self.key + ":" + counter)
+
def send(self, message, eol="$(eol)"):
"""Convenience method to pass messages to an owner."""
if self.owner: self.owner.send(message, eol)
+
+ def can_run(self, command):
+ """Check if the user can run this command object."""
+
+ # has to be in the commands category
+ if command not in universe.categories["command"].values(): result = False
+
+ # avatars of administrators can run any command
+ elif self.owner and self.owner.account.getboolean("administrator"): result = True
+
+ # everyone can run non-administrative commands
+ elif not command.getboolean("administrative"): result = True
+
+ # otherwise the command cannot be run by this actor
+ else: result = False
+
+ # pass back the result
+ return result
+
def go_to(self, location):
"""Relocate the element to a specific location."""
current = self.get("location")
class DataFile:
"""A file containing universe elements."""
def __init__(self, filename, universe):
- self.data = RawConfigParser()
- if access(filename, R_OK): self.data.read(filename)
self.filename = filename
- universe.files[filename] = self
+ self.universe = universe
+ self.load()
+ def load(self):
+ """Read a file and create elements accordingly."""
+ self.modified = False
+ self.data = RawConfigParser()
+ if access(self.filename, R_OK): self.data.read(self.filename)
+ self.universe.files[self.filename] = self
if self.data.has_option("__control__", "include_files"):
includes = makelist(self.data.get("__control__", "include_files"))
else: includes = []
origins = makedict(self.data.get("__control__", "default_files"))
for key in origins.keys():
if not key in includes: includes.append(key)
- universe.default_origins[key] = origins[key]
- if not key in universe.categories:
- universe.categories[key] = {}
+ self.universe.default_origins[key] = origins[key]
+ if not key in self.universe.categories:
+ self.universe.categories[key] = {}
if self.data.has_option("__control__", "private_files"):
for item in makelist(self.data.get("__control__", "private_files")):
if not item in includes: includes.append(item)
- if not item in universe.private_files:
+ if not item in self.universe.private_files:
if not isabs(item):
- item = path_join(dirname(filename), item)
- universe.private_files.append(item)
+ item = path_join(dirname(self.filename), item)
+ self.universe.private_files.append(item)
for section in self.data.sections():
if section != "__control__":
- Element(section, universe, filename)
+ Element(section, self.universe, self.filename)
for include_file in includes:
if not isabs(include_file):
- include_file = path_join(dirname(filename), include_file)
- DataFile(include_file, universe)
+ include_file = path_join(dirname(self.filename), include_file)
+ if include_file not in self.universe.files or not self.universe.files[include_file].is_writeable():
+ DataFile(include_file, self.universe)
def save(self):
"""Write the data, if necessary."""
- # when there is content or the file exists, but is not read-only
- if ( self.data.sections() or exists(self.filename) ) and not ( self.data.has_option("__control__", "read_only") and self.data.getboolean("__control__", "read_only") ):
+ # when modified, writeable and has content or the file exists
+ if self.modified and self.is_writeable() and ( self.data.sections() or exists(self.filename) ):
# make parent directories if necessary
if not exists(dirname(self.filename)):
file_descriptor.flush()
file_descriptor.close()
+ # unset the modified flag
+ self.modified = False
+ def is_writeable(self):
+ """Returns True if the __control__ read_only is False."""
+ return not self.data.has_option("__control__", "read_only") or not self.data.getboolean("__control__", "read_only")
+
class Universe:
"""The universe."""
def __init__(self, filename=""):
self.categories = {}
self.contents = {}
self.default_origins = {}
- self.files = {}
self.private_files = []
- self.loglist = []
+ self.loglines = []
+ self.pending_events_long = {}
+ self.pending_events_short = {}
self.userlist = []
self.terminate_world = False
self.reload_modules = False
if access(filename, R_OK): break
if not isabs(filename):
filename = abspath(filename)
- DataFile(filename, self)
+ self.filename = filename
+ self.load()
+ def load(self):
+ """Load universe data from persistent storage."""
+ self.files = {}
+ DataFile(self.filename, self)
def save(self):
"""Save the universe to persistent storage."""
for key in self.files: self.files[key].save()
-
def initialize_server_socket(self):
"""Create and open the listening socket."""
# note that we're now ready for user connections
log("Waiting for connection(s)...")
+ def get_time(self):
+ """Convenience method to get the elapsed time counter."""
+ return self.categories["internal"]["counters"].getint("elapsed")
+
class User:
"""This is a connected user."""
# replace the input with our cleaned-up text
self.partial_input = text
- def can_run(self, command):
- """Check if the user can run this command object."""
-
- # has to be in the commands category
- if command not in universe.categories["command"].values(): result = False
-
- # administrators can run any command
- elif self.account.getboolean("administrator"): result = True
-
- # everyone can run non-administrative commands
- elif not command.getboolean("administrative"): result = True
-
- # otherwise the command cannot be run by this user
- else: result = False
-
- # pass back the result
- return result
-
def new_avatar(self):
"""Instantiate a new, unconfigured avatar for this user."""
counter = 0
while "avatar:" + self.account.get("name") + ":" + str(counter) in universe.categories["actor"].keys(): counter += 1
self.avatar = Element("actor:avatar:" + self.account.get("name") + ":" + str(counter), universe)
- self.avatar.append("inherit", "template:actor")
+ self.avatar.append("inherit", "archetype:avatar")
self.account.append("avatars", self.avatar.key)
def delete_avatar(self, avatar):
# add to the recent log list
for line in lines:
- while 0 < len(universe.loglist) >= max_log_lines: del universe.loglist[0]
- universe.loglist.append(timestamp + " " + line)
+ while 0 < len(universe.loglines) >= max_log_lines: del universe.loglines[0]
+ universe.loglines.append((level, timestamp + " " + line))
+
+def get_loglines(level, start, stop):
+ """Return a specific range of loglines filtered by level."""
+
+ # filter the log lines
+ loglines = filter(lambda x: x[0]>=level, universe.loglines)
+
+ # we need these in several places
+ total_count = str(len(universe.loglines))
+ filtered_count = len(loglines)
+
+ # don't proceed if there are no lines
+ if filtered_count:
+
+ # can't start before the begining or at the end
+ if start > filtered_count: start = filtered_count
+ if start < 1: start = 1
+
+ # can't stop before we start
+ if stop > start: stop = start
+ elif stop < 1: stop = 1
+
+ # some preamble
+ message = "There are " + str(total_count)
+ message += " log lines in memory and " + str(filtered_count)
+ message += " at or above level " + str(level) + "."
+ message += " The lines from " + str(stop) + " to " + str(start)
+ message += " are:$(eol)$(eol)"
+
+ # add the text from the selected lines
+ if stop > 1: range_lines = loglines[-start:-(stop-1)]
+ else: range_lines = loglines[-start:]
+ for line in range_lines:
+ message += " (" + str(line[0]) + ") " + line[1] + "$(eol)"
+
+ # there were no lines
+ else:
+ message = "None of the " + str(total_count)
+ message += " lines in memory matches your request."
+
+ # pass it back
+ return message
def wrap_ansi_text(text, width):
"""Wrap text with arbitrary width while ignoring ANSI colors."""
def reload_data():
"""Reload data into new persistent objects."""
for user in universe.userlist[:]: user.reload()
+ universe.load()
def check_for_connection(listening_socket):
"""Check for a waiting connection and return a new user object."""
else: command = None
# if it's allowed, do it
- if user.can_run(command): exec(command.get("action"))
+ actor = user.avatar
+ if actor.can_run(command): exec(command.get("action"))
# otherwise, give an error
- elif command_name: command_error(user, input_data)
+ elif command_name: command_error(actor, input_data)
# if no input, just idle back with a prompt
- else: user.send("", just_prompt=True)
+ else: actor("", just_prompt=True)
-def command_halt(user, parameters):
+def command_halt(actor, parameters):
"""Halt the world."""
+ if actor.owner:
- # see if there's a message or use a generic one
- if parameters: message = "Halting: " + parameters
- else: message = "User " + user.account.get("name") + " halted the world."
+ # see if there's a message or use a generic one
+ if parameters: message = "Halting: " + parameters
+ else: message = "User " + actor.owner.account.get("name") + " halted the world."
- # let everyone know
- broadcast(message, add_prompt=False)
- log(message, 8)
+ # let everyone know
+ broadcast(message, add_prompt=False)
+ log(message, 8)
- # set a flag to terminate the world
- universe.terminate_world = True
+ # set a flag to terminate the world
+ universe.terminate_world = True
-def command_reload(user):
+def command_reload(actor):
"""Reload all code modules, configs and data."""
+ if actor.owner:
- # let the user know and log
- user.send("Reloading all code modules, configs and data.")
- log("User " + user.account.get("name") + " reloaded the world.", 8)
+ # let the user know and log
+ actor.send("Reloading all code modules, configs and data.")
+ log("User " + actor.owner.account.get("name") + " reloaded the world.", 8)
- # set a flag to reload
- universe.reload_modules = True
+ # set a flag to reload
+ universe.reload_modules = True
-def command_quit(user):
+def command_quit(actor):
"""Leave the world and go back to the main menu."""
- user.deactivate_avatar()
- user.state = "main_utility"
+ if actor.owner:
+ actor.owner.state = "main_utility"
+ actor.owner.deactivate_avatar()
-def command_help(user, parameters):
+def command_help(actor, parameters):
"""List available commands and provide help for commands."""
# did the user ask for help on a specific command word?
- if parameters:
+ if parameters and actor.owner:
# is the command word one for which we have data?
if parameters in universe.categories["command"]:
else: command = None
# only for allowed commands
- if user.can_run(command):
+ if actor.can_run(command):
# add a description if provided
description = command.get("description")
sorted_commands.sort()
for item in sorted_commands:
command = universe.categories["command"][item]
- if user.can_run(command):
+ if actor.can_run(command):
description = command.get("description")
if not description:
description = "(no short description provided)"
output += "$(eol)Enter \"help COMMAND\" for help on a command named \"COMMAND\"."
# send the accumulated output to the user
- user.send(output)
+ actor.send(output)
-def command_move(user, parameters):
+def command_move(actor, parameters):
"""Move the avatar in a given direction."""
- if parameters in universe.contents[user.avatar.get("location")].portals():
- user.avatar.move_direction(parameters)
- else: user.send("You cannot go that way.")
+ if parameters in universe.contents[actor.get("location")].portals():
+ actor.move_direction(parameters)
+ else: actor.send("You cannot go that way.")
-def command_look(user, parameters):
+def command_look(actor, parameters):
"""Look around."""
- if parameters: user.send("You look at or in anything yet.")
- else: user.avatar.look_at(user.avatar.get("location"))
+ if parameters: actor.send("You can't look at or in anything yet.")
+ else: actor.look_at(actor.get("location"))
-def command_say(user, parameters):
+def command_say(actor, parameters):
"""Speak to others in the same room."""
# check for replacement macros
- if replace_macros(user, parameters, True) != parameters:
- user.send("You cannot speak $_(replacement macros).")
+ if replace_macros(actor.owner, parameters, True) != parameters:
+ actor.send("You cannot speak $_(replacement macros).")
# the user entered a message
elif parameters:
message = message.replace(" " + word + " ", " " + word.capitalize() + " ")
# tell the room
- user.avatar.echo_to_location(user.avatar.get("name") + " " + action + "s, \"" + message + "\"")
- user.send("You " + action + ", \"" + message + "\"")
+ actor.echo_to_location(actor.get("name") + " " + action + "s, \"" + message + "\"")
+ actor.send("You " + action + ", \"" + message + "\"")
# there was no message
else:
- user.send("What do you want to say?")
+ actor.send("What do you want to say?")
-def command_show(user, parameters):
+def command_show(actor, parameters):
"""Show program data."""
message = ""
- if parameters.find(" ") < 1:
- if parameters == "time":
- message = universe.categories["internal"]["counters"].get("elapsed") + " increments elapsed since the world was created."
- elif parameters == "categories":
- message = "These are the element categories:$(eol)"
- categories = universe.categories.keys()
- categories.sort()
- for category in categories: message += "$(eol) $(grn)" + category + "$(nrm)"
- elif parameters == "files":
- message = "These are the current files containing the universe:$(eol)"
- filenames = universe.files.keys()
- filenames.sort()
- for filename in filenames: message += "$(eol) $(grn)" + filename + "$(nrm)"
- else: message = ""
- else:
- arguments = parameters.split()
- if arguments[0] == "category":
- if arguments[1] in universe.categories:
- message = "These are the elements in the \"" + arguments[1] + "\" category:$(eol)"
- elements = universe.categories[arguments[1]].keys()
- elements.sort()
- for element in elements:
- message += "$(eol) $(grn)" + universe.categories[arguments[1]][element].key + "$(nrm)"
- elif arguments[0] == "element":
- if arguments[1] in universe.contents:
- message = "These are the properties of the \"" + arguments[1] + "\" element:$(eol)"
- element = universe.contents[arguments[1]]
- facets = element.facets()
- facets.sort()
- for facet in facets:
- message += "$(eol) $(grn)" + facet + ": $(red)" + escape_macros(element.get(facet)) + "$(nrm)"
- elif arguments[0] == "result":
- if len(arguments) > 1:
- try:
- message = repr(eval(" ".join(arguments[1:])))
- except:
- message = "Your expression raised an exception!"
- elif arguments[0] == "log":
- if match("^\d+$", arguments[1]) and int(arguments[1]) > 0:
- linecount = int(arguments[1])
- if linecount > len(universe.loglist): linecount = len(universe.loglist)
- message = "There are " + str(len(universe.loglist)) + " log lines in memory."
- message += " The most recent " + str(linecount) + " lines are:$(eol)$(eol)"
- for line in universe.loglist[-linecount:]:
- message += " " + line + "$(eol)"
- else: message = "\"" + arguments[1] + "\" is not a positive integer greater than 0."
- if not message:
- if parameters: message = "I don't know what \"" + parameters + "\" is."
- else: message = "What do you want to show?"
- user.send(message)
-
-def command_create(user, parameters):
+ arguments = parameters.split()
+ if not parameters: message = "What do you want to show?"
+ elif arguments[0] == "time":
+ message = universe.categories["internal"]["counters"].get("elapsed") + " increments elapsed since the world was created."
+ elif arguments[0] == "categories":
+ message = "These are the element categories:$(eol)"
+ categories = universe.categories.keys()
+ categories.sort()
+ for category in categories: message += "$(eol) $(grn)" + category + "$(nrm)"
+ elif arguments[0] == "files":
+ message = "These are the current files containing the universe:$(eol)"
+ filenames = universe.files.keys()
+ filenames.sort()
+ for filename in filenames:
+ if universe.files[filename].is_writeable(): status = "rw"
+ else: status = "ro"
+ message += "$(eol) $(red)(" + status + ") $(grn)" + filename + "$(nrm)"
+ elif arguments[0] == "category":
+ if len(arguments) != 2: message = "You must specify one category."
+ elif arguments[1] in universe.categories:
+ message = "These are the elements in the \"" + arguments[1] + "\" category:$(eol)"
+ elements = [(universe.categories[arguments[1]][x].key) for x in universe.categories[arguments[1]].keys()]
+ elements.sort()
+ for element in elements:
+ message += "$(eol) $(grn)" + element + "$(nrm)"
+ else: message = "Category \"" + arguments[1] + "\" does not exist."
+ elif arguments[0] == "file":
+ if len(arguments) != 2: message = "You must specify one file."
+ elif arguments[1] in universe.files:
+ message = "These are the elements in the \"" + arguments[1] + "\" file:$(eol)"
+ elements = universe.files[arguments[1]].data.sections()
+ elements.sort()
+ for element in elements:
+ message += "$(eol) $(grn)" + element + "$(nrm)"
+ else: message = "Category \"" + arguments[1] + "\" does not exist."
+ elif arguments[0] == "element":
+ if len(arguments) != 2: message = "You must specify one element."
+ elif arguments[1] in universe.contents:
+ element = universe.contents[arguments[1]]
+ message = "These are the properties of the \"" + arguments[1] + "\" element (in \"" + element.origin.filename + "\"):$(eol)"
+ facets = element.facets()
+ facets.sort()
+ for facet in facets:
+ message += "$(eol) $(grn)" + facet + ": $(red)" + escape_macros(element.get(facet)) + "$(nrm)"
+ else: message = "Element \"" + arguments[1] + "\" does not exist."
+ elif arguments[0] == "result":
+ if len(arguments) < 2: message = "You need to specify an expression."
+ else:
+ try:
+ message = repr(eval(" ".join(arguments[1:])))
+ except:
+ message = "Your expression raised an exception!"
+ elif arguments[0] == "log":
+ if len(arguments) == 4:
+ if match("^\d+$", arguments[3]) and int(arguments[3]) >= 0:
+ stop = int(arguments[3])
+ else: stop = -1
+ else: stop = 0
+ if len(arguments) >= 3:
+ if match("^\d+$", arguments[2]) and int(arguments[2]) > 0:
+ start = int(arguments[2])
+ else: start = -1
+ else: start = 10
+ if len(arguments) >= 2:
+ if match("^\d+$", arguments[1]) and 0 <= int(arguments[1]) <= 9:
+ level = int(arguments[1])
+ else: level = -1
+ else: level = 1
+ if level > -1 and start > -1 and stop > -1:
+ message = get_loglines(level, start, stop)
+ else: message = "When specified, level must be 0-9 (default 1), start and stop must be >=1 (default 10 and 1)."
+ else: message = "I don't know what \"" + parameters + "\" is."
+ actor.send(message)
+
+def command_create(actor, parameters):
"""Create an element if it does not exist."""
if not parameters: message = "You must at least specify an element to create."
+ elif not actor.owner: message = ""
else:
arguments = parameters.split()
if len(arguments) == 1: arguments.append("")
if element in universe.contents: message = "The \"" + element + "\" element already exists."
else:
message = "You create \"" + element + "\" within the universe."
- logline = user.account.get("name") + " created an element: " + element
+ logline = actor.owner.account.get("name") + " created an element: " + element
if filename:
logline += " in file " + filename
if filename not in universe.files:
Element(element, universe, filename)
log(logline, 6)
elif len(arguments) > 2: message = "You can only specify an element and a filename."
- user.send(message)
+ actor.send(message)
-def command_destroy(user, parameters):
+def command_destroy(actor, parameters):
"""Destroy an element if it exists."""
- if not parameters: message = "You must specify an element to destroy."
- else:
- if parameters not in universe.contents: message = "The \"" + parameters + "\" element does not exist."
+ if actor.owner:
+ if not parameters: message = "You must specify an element to destroy."
else:
- universe.contents[parameters].destroy()
- message = "You destroy \"" + parameters + "\" within the universe."
- log(user.account.get("name") + " destroyed an element: " + parameters, 6)
- user.send(message)
+ if parameters not in universe.contents: message = "The \"" + parameters + "\" element does not exist."
+ else:
+ universe.contents[parameters].destroy()
+ message = "You destroy \"" + parameters + "\" within the universe."
+ log(actor.owner.account.get("name") + " destroyed an element: " + parameters, 6)
+ actor.send(message)
-def command_set(user, parameters):
+def command_set(actor, parameters):
"""Set a facet of an element."""
if not parameters: message = "You must specify an element, a facet and a value."
else:
else:
universe.contents[element].set(facet, value)
message = "You have successfully (re)set the \"" + facet + "\" facet of element \"" + element + "\". Try \"show element " + element + "\" for verification."
- user.send(message)
+ actor.send(message)
-def command_delete(user, parameters):
+def command_delete(actor, parameters):
"""Delete a facet from an element."""
if not parameters: message = "You must specify an element and a facet."
else:
if element not in universe.contents: message = "The \"" + element + "\" element does not exist."
elif facet not in universe.contents[element].facets(): message = "The \"" + element + "\" element has no \"" + facet + "\" facet."
else:
- universe.contents[element].delete(facet)
+ universe.contents[element].remove_facet(facet)
message = "You have successfully deleted the \"" + facet + "\" facet of element \"" + element + "\". Try \"show element " + element + "\" for verification."
- user.send(message)
+ actor.send(message)
-def command_error(user, input_data):
+def command_error(actor, input_data):
"""Generic error for an unrecognized command word."""
# 90% of the time use a generic error
message = "Arglebargle, glop-glyf!?!"
# send the error message
- user.send(message)
+ actor.send(message)
# if there is no universe, create an empty one
if not "universe" in locals(): universe = Universe()