From 1314629a066efa34f62f24aff78ad07603e5f65c Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 2 May 2009 15:55:47 +0000 Subject: [PATCH] Minor bugfix of addcom command, some other cleanup. --- game/gamesrc/parents/examples/red_button.py | 5 ----- src/commands/comsys.py | 24 ++++++++++----------- src/commands/objmanip.py | 6 ++++-- src/config_defaults.py | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/game/gamesrc/parents/examples/red_button.py b/game/gamesrc/parents/examples/red_button.py index 64185c54f..14fb786a9 100644 --- a/game/gamesrc/parents/examples/red_button.py +++ b/game/gamesrc/parents/examples/red_button.py @@ -64,11 +64,6 @@ class RedButton(BasicObject): """ This function is called when object is created. Use this preferably over __init__. - - In this case all we do is add the commandtable - to the object's own command_table variable; this makes - the commands we've added to COMMAND_TABLE available to - the user whenever the object is around. """ #get stored object related to this class obj = self.scripted_obj diff --git a/src/commands/comsys.py b/src/commands/comsys.py index 7d80ccc40..f592a6e7a 100644 --- a/src/commands/comsys.py +++ b/src/commands/comsys.py @@ -19,20 +19,20 @@ def cmd_addcom(command): addcom foo=Bar """ source_object = command.source_object + command_argument = command.command_argument - if not command.command_argument: - source_object.emit_to("You need to specify a channel alias and name.") - return - - eq_args = command.command_argument.split('=', 1) - - chan_alias = eq_args[0] - chan_name = eq_args[1] - - if len(eq_args) < 2 or len(chan_name) == 0: - source_object.emit_to("You need to specify a channel name.") - return + if not command_argument: + source_object.emit_to("Usage: addcom [alias=]channelname.") + return + command_argument + if '=' in command_argument: + chan_alias, chan_name = command.command_argument.split('=', 1) + chan_alias, chan_name = chan_alias.strip(), chan_name.strip() + else: + chan_name = command_argument.strip() + chan_alias = chan_name + if chan_alias in command.session.channels_subscribed: source_object.emit_to("You are already on that channel.") return diff --git a/src/commands/objmanip.py b/src/commands/objmanip.py index 2fa465709..974b76ec2 100644 --- a/src/commands/objmanip.py +++ b/src/commands/objmanip.py @@ -257,9 +257,11 @@ def cmd_find(command): if len(results) > 0: source_object.emit_to("Name matches for: %s" % (searchstring,)) + s = "" for result in results: - source_object.emit_to(" %s" % (result.get_name(fullname=True),)) - source_object.emit_to("%d matches returned." % (len(results),)) + s += " %s\n\r" % (result.get_name(fullname=True),) + s += "%d matches returned." % (len(results),) + source_object.emit_to(s) else: source_object.emit_to("No name matches found for: %s" % (searchstring,)) GLOBAL_CMD_TABLE.add_command("@find", cmd_find, diff --git a/src/config_defaults.py b/src/config_defaults.py index ac333bb88..cff77ee65 100644 --- a/src/config_defaults.py +++ b/src/config_defaults.py @@ -279,4 +279,4 @@ try: import django_extensions INSTALLED_APPS = INSTALLED_APPS + ('django_extensions',) except ImportError: - pass \ No newline at end of file + pass