After lots of discussions, default commands where moved from game/gamesrc/commands/default to src/commands/default in order to make it clearer which parts are updated as part of evennia and which can be tweaked at heart's content. New templates where left in gamesrc/commands that should hopefully make it clearer how to extend the command system. Also game/web was moved to src/web - we'll likely extend this from game/gamesrc/web in the future. If you already did extensions you should just have to edit your import paths and make use of the new cmdset template supplied.

The unit testing was for commands was split out from src/objects/tests.py into the new src/commands/default/test.py in order to keep the testing modules thematically grouped with the things they are testing.
This commit is contained in:
Griatch 2010-11-23 01:24:56 +00:00
parent a3917073ff
commit 72d40285b8
61 changed files with 381 additions and 184 deletions

View file

@ -0,0 +1,65 @@
"""
This is the second component of using a Command in your game - a
command set. A cmdset groups any number of commands together. CmdSets
are stored on character and objects and all available cmdsets are
searched when Evennia tries to determine if a command is
available. Sets can be merged and combined in many different ways (see
the docs).
You can use the classes below as templates for extending the game with
new command sets; you can also import the default Evennia cmdset and
extend/overload that.
To change default cmdset (the one all character start the game with),
Create your custom commands in other modules
(inheriting from game.gamesrc.commands.basecommand), add them to a
cmdset class, then set your settings.CMDSET_DEFAULT to point to this
new cmdset class.
"""
from src.commands.cmdset import CmdSet
from src.commands.default import cmdset_default
from game.gamesrc.commands.basecommands 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):
"""
This is an example of how to overload the default command
set defined in src/commands/default/cmdset_default.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_DEFAULT to point
to this class.
"""
key = "DefaultMUX"
def at_cmdset_creation(self):
"""
Populates the cmdset
"""
super(ExtendedDefaultSet, self).at_cmdset_creation()
#
# any commands you add below will overload the default ones.
#