From ecefbfac01d96cb447ecf12822da47b29aaba5f1 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 23 Nov 2010 18:10:41 +0000 Subject: [PATCH] Set the default settings file to point to the files in game/gamesrc/commands - these now make for good starts for overriding the default systems. The system now also matches the examples given in the wiki. --- .../{empty_cmdset.py => basecmdset.py} | 68 +++++++++++++------ src/commands/cmdsethandler.py | 2 +- src/settings_default.py | 4 +- 3 files changed, 50 insertions(+), 24 deletions(-) rename game/gamesrc/commands/{empty_cmdset.py => basecmdset.py} (62%) diff --git a/game/gamesrc/commands/empty_cmdset.py b/game/gamesrc/commands/basecmdset.py similarity index 62% rename from game/gamesrc/commands/empty_cmdset.py rename to game/gamesrc/commands/basecmdset.py index b525dff3df..5d68ab8f36 100644 --- a/game/gamesrc/commands/empty_cmdset.py +++ b/game/gamesrc/commands/basecmdset.py @@ -19,28 +19,11 @@ new cmdset class. """ from src.commands.cmdset import CmdSet -from src.commands.default import cmdset_default +from src.commands.default import cmdset_default, cmdset_unloggedin -from game.gamesrc.commands.basecommands import Command +from game.gamesrc.commands.basecommand import Command -class ExampleCmdSet(CmdSet): - """ - Implements an example cmdset. - """ - - key = "ExampleSet" - - def at_cmdset_creation(self): - """ - This is the only method defined in a cmdset, called during - its creation. It should populate the set with command instances. - - Here we just add the base Command object. - """ - self.add(Command()) - - -class ExtendedDefaultSet(cmdset_default.DefaultCmdSet): +class DefaultCmdSet(cmdset_default.DefaultCmdSet): """ This is an example of how to overload the default command set defined in src/commands/default/cmdset_default.py. @@ -56,10 +39,53 @@ class ExtendedDefaultSet(cmdset_default.DefaultCmdSet): """ Populates the cmdset """ - super(ExtendedDefaultSet, self).at_cmdset_creation() + super(DefaultCmdSet, self).at_cmdset_creation() # # any commands you add below will overload the default ones. # + +class UnloggedinCmdSet(cmdset_unloggedin.UnloggedinCmdSet): + """ + This is an example of how to overload the command set of the + unlogged in commands, defined in + src/commands/default/cmdset_unloggedin.py. + + Here we copy everything by calling the parent, but you can + copy&paste any combination of the default command to customize + your default set. Next you change settings.CMDSET_UNLOGGEDIN to + point to this class. + """ + key = "Unloggedin" + + def at_cmdset_creation(self): + """ + Populates the cmdset + """ + super(UnloggedinCmdSet, self).at_cmdset_creation() + + # + # any commands you add below will overload the default ones. + # + + +class BaseCmdSet(CmdSet): + """ + Implements an empty, example cmdset. + """ + + key = "ExampleSet" + + def at_cmdset_creation(self): + """ + This is the only method defined in a cmdset, called during + its creation. It should populate the set with command instances. + + Here we just add the base Command object. + """ + self.add(Command()) + + + diff --git a/src/commands/cmdsethandler.py b/src/commands/cmdsethandler.py index 763d98a7e4..2f19b350d3 100644 --- a/src/commands/cmdsethandler.py +++ b/src/commands/cmdsethandler.py @@ -111,7 +111,7 @@ def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False): raise except KeyError: errstring = "Error in loading cmdset: No cmdset class '%s' in %s." - errstring = errstring % (modulepath, classname) + errstring = errstring % (classname, modulepath) raise except Exception: errstring = "\n%s\nCompile/Run error when loading cmdset '%s'." diff --git a/src/settings_default.py b/src/settings_default.py index 53d8d9493c..86cb01c4e5 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -136,9 +136,9 @@ ALTERNATE_OBJECT_SEARCH_MULTIMATCH_PARSER = "" ################################################### # Command set used before player has logged in -CMDSET_UNLOGGEDIN = "src.commands.default.cmdset_unloggedin.UnloggedinCmdSet" +CMDSET_UNLOGGEDIN = "game.gamesrc.commands.basecmdset.UnloggedinCmdSet" # Default set for logged in players (fallback) -CMDSET_DEFAULT = "src.commands.default.cmdset_default.DefaultCmdSet" +CMDSET_DEFAULT = "game.gamesrc.commands.basecmdset.DefaultCmdSet" ###################################################