More whitespace cleanup.
This commit is contained in:
parent
c0322c9eae
commit
45c5be8468
43 changed files with 1116 additions and 1131 deletions
|
|
@ -1,10 +1,10 @@
|
|||
"""
|
||||
Example command set template module.
|
||||
Example command set template module.
|
||||
|
||||
To create new commands to populate the cmdset, see
|
||||
examples/command.py.
|
||||
|
||||
To extend the default command set:
|
||||
To extend the default command set:
|
||||
- copy this file up one level to gamesrc/commands and name it
|
||||
something fitting.
|
||||
- change settings.CMDSET_DEFAULT to point to the new module's
|
||||
|
|
@ -36,12 +36,12 @@ class ExampleCmdSet(CmdSet):
|
|||
"""
|
||||
Implements an empty, example cmdset.
|
||||
"""
|
||||
|
||||
|
||||
key = "ExampleSet"
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"""
|
||||
This is the only method defined in a cmdset, called during
|
||||
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 empty base Command object. It prints some info.
|
||||
|
|
@ -51,7 +51,7 @@ class ExampleCmdSet(CmdSet):
|
|||
|
||||
class DefaultCmdSet(default_cmds.DefaultCmdSet):
|
||||
"""
|
||||
This is an example of how to overload the default command
|
||||
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
|
||||
|
|
@ -60,7 +60,7 @@ class DefaultCmdSet(default_cmds.DefaultCmdSet):
|
|||
to this class.
|
||||
"""
|
||||
key = "DefaultMUX"
|
||||
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"""
|
||||
Populates the cmdset
|
||||
|
|
@ -72,8 +72,8 @@ class DefaultCmdSet(default_cmds.DefaultCmdSet):
|
|||
# any commands you add below will overload the default ones.
|
||||
#
|
||||
#self.add(menusystem.CmdMenuTest())
|
||||
#self.add(lineeditor.CmdEditor())
|
||||
#self.add(misc_commands.CmdQuell())
|
||||
#self.add(lineeditor.CmdEditor())
|
||||
#self.add(misc_commands.CmdQuell())
|
||||
|
||||
class UnloggedinCmdSet(default_cmds.UnloggedinCmdSet):
|
||||
"""
|
||||
|
|
@ -87,25 +87,25 @@ class UnloggedinCmdSet(default_cmds.UnloggedinCmdSet):
|
|||
point to this class.
|
||||
"""
|
||||
key = "Unloggedin"
|
||||
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"""
|
||||
Populates the cmdset
|
||||
"""
|
||||
# calling setup in src.commands.default.cmdset_unloggedin
|
||||
super(UnloggedinCmdSet, self).at_cmdset_creation()
|
||||
|
||||
|
||||
#
|
||||
# any commands you add below will overload the default ones.
|
||||
#
|
||||
|
||||
class OOCCmdSet(default_cmds.OOCCmdSet):
|
||||
"""
|
||||
This is set is available to the player when they have no
|
||||
This is set is available to the player when they have no
|
||||
character connected to them (i.e. they are out-of-character, ooc).
|
||||
"""
|
||||
key = "OOC"
|
||||
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"""
|
||||
Populates the cmdset
|
||||
|
|
@ -114,9 +114,4 @@ class OOCCmdSet(default_cmds.OOCCmdSet):
|
|||
super(OOCCmdSet, self).at_cmdset_creation()
|
||||
#
|
||||
# any commands you add below will overload the default ones.
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
"""
|
||||
This defines the cmdset for the red_button. Here we have defined
|
||||
the commands and the cmdset in the same module, but if you
|
||||
have many different commands to merge it is often better
|
||||
have many different commands to merge it is often better
|
||||
to define the cmdset separately, picking and choosing from
|
||||
among the available commands as to what should be included in the
|
||||
among the available commands as to what should be included in the
|
||||
cmdset - this way you can often re-use the commands too.
|
||||
"""
|
||||
|
||||
import random
|
||||
import random
|
||||
from ev import Command, CmdSet
|
||||
|
||||
# Some simple commands for the red button
|
||||
|
|
@ -19,14 +19,14 @@ from ev import Command, CmdSet
|
|||
class CmdNudge(Command):
|
||||
"""
|
||||
Try to nudge the button's lid
|
||||
|
||||
Usage:
|
||||
|
||||
Usage:
|
||||
nudge lid
|
||||
|
||||
This command will have you try to
|
||||
push the lid of the button away.
|
||||
This command will have you try to
|
||||
push the lid of the button away.
|
||||
"""
|
||||
|
||||
|
||||
key = "nudge lid" # two-word command name!
|
||||
aliases = ["nudge"]
|
||||
locks = "cmd:all()"
|
||||
|
|
@ -43,10 +43,10 @@ class CmdNudge(Command):
|
|||
else:
|
||||
self.caller.msg("You manage to get a nail under the lid.")
|
||||
self.caller.execute_cmd("open lid")
|
||||
|
||||
|
||||
class CmdPush(Command):
|
||||
"""
|
||||
Push the red button
|
||||
Push the red button
|
||||
|
||||
Usage:
|
||||
push button
|
||||
|
|
@ -55,7 +55,7 @@ class CmdPush(Command):
|
|||
key = "push button"
|
||||
aliases = ["push", "press button", "press"]
|
||||
locks = "cmd:all()"
|
||||
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Note that we choose to implement this with checking for
|
||||
|
|
@ -64,7 +64,7 @@ class CmdPush(Command):
|
|||
|
||||
An alternative would be to make two versions of this command
|
||||
and tuck them into the cmdset linked to the Open and Closed
|
||||
lid-state respectively.
|
||||
lid-state respectively.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -72,15 +72,15 @@ class CmdPush(Command):
|
|||
string = "You reach out to press the big red button ..."
|
||||
string += "\n\nA BOOM! A bright light blinds you!"
|
||||
string += "\nThe world goes dark ..."
|
||||
self.caller.msg(string)
|
||||
self.caller.location.msg_contents("%s presses the button. BOOM! %s is blinded by a flash!" %
|
||||
self.caller.msg(string)
|
||||
self.caller.location.msg_contents("%s presses the button. BOOM! %s is blinded by a flash!" %
|
||||
(self.caller.name, self.caller.name), exclude=self.caller)
|
||||
# the button's method will handle all setup of scripts etc.
|
||||
self.obj.press_button(self.caller)
|
||||
self.obj.press_button(self.caller)
|
||||
else:
|
||||
string = "You cannot push the button - there is a glass lid covering it."
|
||||
self.caller.msg(string)
|
||||
|
||||
|
||||
|
||||
|
||||
class CmdSmashGlass(Command):
|
||||
|
|
@ -92,15 +92,15 @@ class CmdSmashGlass(Command):
|
|||
|
||||
Try to smash the glass of the button.
|
||||
"""
|
||||
|
||||
|
||||
key = "smash glass"
|
||||
aliases = ["smash lid", "break lid", "smash"]
|
||||
locks = "cmd:all()"
|
||||
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
The lid won't open, but there is a small chance
|
||||
of causing the lamp to break.
|
||||
of causing the lamp to break.
|
||||
"""
|
||||
rand = random.random()
|
||||
|
||||
|
|
@ -109,11 +109,11 @@ class CmdSmashGlass(Command):
|
|||
string += " with all your might. The lid won't budge"
|
||||
string += " but you cause quite the tremor through the button's mount."
|
||||
string += "\nIt looks like the button's lamp stopped working for the time being."
|
||||
self.obj.lamp_works = False
|
||||
self.obj.lamp_works = False
|
||||
elif rand < 0.6:
|
||||
string = "You hit the lid hard. It doesn't move an inch."
|
||||
else:
|
||||
string = "You place a well-aimed fist against the glass of the lid."
|
||||
string = "You place a well-aimed fist against the glass of the lid."
|
||||
string += " Unfortunately all you get is a pain in your hand. Maybe"
|
||||
string += " you should just try to open the lid instead?"
|
||||
self.caller.msg(string)
|
||||
|
|
@ -125,7 +125,7 @@ class CmdOpenLid(Command):
|
|||
open lid
|
||||
|
||||
Usage:
|
||||
open lid
|
||||
open lid
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -135,21 +135,21 @@ class CmdOpenLid(Command):
|
|||
|
||||
def func(self):
|
||||
"simply call the right function."
|
||||
|
||||
|
||||
if self.obj.db.lid_locked:
|
||||
self.caller.msg("This lid seems locked in place for the moment.")
|
||||
return
|
||||
return
|
||||
|
||||
string = "\nA ticking sound is heard, like a winding mechanism. Seems "
|
||||
string += "the lid will soon close again."
|
||||
self.caller.msg(string)
|
||||
self.caller.location.msg_contents("%s opens the lid of the button." %
|
||||
self.caller.location.msg_contents("%s opens the lid of the button." %
|
||||
(self.caller.name), exclude=self.caller)
|
||||
# add the relevant cmdsets to button
|
||||
# add the relevant cmdsets to button
|
||||
self.obj.cmdset.add(LidClosedCmdSet)
|
||||
# call object method
|
||||
self.obj.open_lid()
|
||||
|
||||
|
||||
class CmdCloseLid(Command):
|
||||
"""
|
||||
close the lid
|
||||
|
|
@ -163,7 +163,7 @@ class CmdCloseLid(Command):
|
|||
key = "close lid"
|
||||
aliases = ["close"]
|
||||
locks = "cmd:all()"
|
||||
|
||||
|
||||
def func(self):
|
||||
"Close the lid"
|
||||
|
||||
|
|
@ -171,9 +171,9 @@ class CmdCloseLid(Command):
|
|||
|
||||
# this will clean out scripts dependent on lid being open.
|
||||
self.caller.msg("You close the button's lid. It clicks back into place.")
|
||||
self.caller.location.msg_contents("%s closes the button's lid." %
|
||||
self.caller.location.msg_contents("%s closes the button's lid." %
|
||||
(self.caller.name), exclude=self.caller)
|
||||
|
||||
|
||||
class CmdBlindLook(Command):
|
||||
"""
|
||||
Looking around in darkness
|
||||
|
|
@ -185,14 +185,14 @@ class CmdBlindLook(Command):
|
|||
|
||||
"""
|
||||
|
||||
key = "look"
|
||||
key = "look"
|
||||
aliases = ["l", "get", "examine", "ex", "feel", "listen"]
|
||||
locks = "cmd:all()"
|
||||
|
||||
|
||||
def func(self):
|
||||
"This replaces all the senses when blinded."
|
||||
|
||||
# we decide what to reply based on which command was
|
||||
# we decide what to reply based on which command was
|
||||
# actually tried
|
||||
|
||||
if self.cmdstring == "get":
|
||||
|
|
@ -208,7 +208,7 @@ class CmdBlindLook(Command):
|
|||
string = "You are temporarily blinded by the flash. "
|
||||
string += "Until it wears off, all you can do is feel around blindly."
|
||||
self.caller.msg(string)
|
||||
self.caller.location.msg_contents("%s stumbles around, blinded." %
|
||||
self.caller.location.msg_contents("%s stumbles around, blinded." %
|
||||
(self.caller.name), exclude=self.caller)
|
||||
|
||||
class CmdBlindHelp(Command):
|
||||
|
|
@ -220,7 +220,7 @@ class CmdBlindHelp(Command):
|
|||
|
||||
"""
|
||||
key = "help"
|
||||
aliases = "h"
|
||||
aliases = "h"
|
||||
locks = "cmd:all()"
|
||||
|
||||
def func(self):
|
||||
|
|
@ -242,13 +242,13 @@ class DefaultCmdSet(CmdSet):
|
|||
The default cmdset always sits
|
||||
on the button object and whereas other
|
||||
command sets may be added/merge onto it
|
||||
and hide it, removing them will always
|
||||
and hide it, removing them will always
|
||||
bring it back. It's added to the object
|
||||
using obj.cmdset.add_default().
|
||||
"""
|
||||
key = "RedButtonDefault"
|
||||
mergetype = "Union" # this is default, we don't really need to put it here.
|
||||
|
||||
mergetype = "Union" # this is default, we don't really need to put it here.
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"Init the cmdset"
|
||||
self.add(CmdPush())
|
||||
|
|
@ -260,13 +260,13 @@ class LidClosedCmdSet(CmdSet):
|
|||
It contains the commands that launches the other
|
||||
command sets, making the red button a self-contained
|
||||
item (i.e. you don't have to manually add any
|
||||
scripts etc to it when creating it).
|
||||
scripts etc to it when creating it).
|
||||
"""
|
||||
key = "LidClosedCmdSet"
|
||||
# default Union is used *except* if we are adding to a
|
||||
# cmdset named LidOpenCmdSet - this one we replace
|
||||
# default Union is used *except* if we are adding to a
|
||||
# cmdset named LidOpenCmdSet - this one we replace
|
||||
# completely.
|
||||
key_mergetype = {"LidOpenCmdSet": "Replace"}
|
||||
key_mergetype = {"LidOpenCmdSet": "Replace"}
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"Populates the cmdset when it is instantiated."
|
||||
|
|
@ -276,14 +276,14 @@ class LidClosedCmdSet(CmdSet):
|
|||
|
||||
class LidOpenCmdSet(CmdSet):
|
||||
"""
|
||||
This is the opposite of the Closed cmdset.
|
||||
This is the opposite of the Closed cmdset.
|
||||
"""
|
||||
key = "LidOpenCmdSet"
|
||||
# default Union is used *except* if we are adding to a
|
||||
# cmdset named LidClosedCmdSet - this one we replace
|
||||
# default Union is used *except* if we are adding to a
|
||||
# cmdset named LidClosedCmdSet - this one we replace
|
||||
# completely.
|
||||
key_mergetype = {"LidClosedCmdSet": "Replace"}
|
||||
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"setup the cmdset (just one command)"
|
||||
self.add(CmdCloseLid())
|
||||
|
|
@ -295,13 +295,13 @@ class BlindCmdSet(CmdSet):
|
|||
"""
|
||||
key = "BlindCmdSet"
|
||||
# we want it to completely replace all normal commands
|
||||
# until the timed script removes it again.
|
||||
mergetype = "Replace"
|
||||
# until the timed script removes it again.
|
||||
mergetype = "Replace"
|
||||
# we want to stop the player from walking around
|
||||
# in this blinded state, so we hide all exits too.
|
||||
# (channel commands will still work).
|
||||
no_exits = True # keep player in the same room
|
||||
no_objs = True # don't allow object commands
|
||||
no_objs = True # don't allow object commands
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"Setup the blind cmdset"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Example command module template
|
||||
Example command module template
|
||||
|
||||
Copy this module up one level to gamesrc/commands/ and name it as
|
||||
befits your use. You can then use it as a template to define your new
|
||||
|
|
@ -15,30 +15,30 @@ from ev import utils
|
|||
class Command(BaseCommand):
|
||||
"""
|
||||
Inherit from this if you want to create your own
|
||||
command styles. Note that Evennia's default commands
|
||||
command styles. Note that Evennia's default commands
|
||||
use MuxCommand instead (next in this module)
|
||||
|
||||
Note that the class's __doc__ string (this text) is
|
||||
used by Evennia to create the automatic help entry for
|
||||
the command, so make sure to document consistently here.
|
||||
the command, so make sure to document consistently here.
|
||||
|
||||
"""
|
||||
# these need to be specified
|
||||
|
||||
# these need to be specified
|
||||
|
||||
key = "MyCommand"
|
||||
aliases = ["mycmd", "myc"]
|
||||
aliases = ["mycmd", "myc"]
|
||||
locks = "cmd:all()"
|
||||
help_category = "General"
|
||||
|
||||
# auto_help = False # uncomment to deactive auto-help for this command.
|
||||
# arg_regex = r"\s.*?|$" # optional regex detailing how the part after
|
||||
# arg_regex = r"\s.*?|$" # optional regex detailing how the part after
|
||||
# the cmdname must look to match this command.
|
||||
|
||||
|
||||
# (we don't implement hook method access() here, you don't need to
|
||||
# modify that unless you want to change how the lock system works
|
||||
# (in that case see src.commands.command.Command))
|
||||
|
||||
|
||||
def at_pre_cmd(self):
|
||||
"""
|
||||
This hook is called before self.parse() on all commands
|
||||
|
|
@ -51,15 +51,15 @@ class Command(BaseCommand):
|
|||
has been identified. It creates a new set of member variables
|
||||
that can be later accessed from self.func() (see below)
|
||||
|
||||
The following variables are available to us:
|
||||
# class variables:
|
||||
The following variables are available to us:
|
||||
# class variables:
|
||||
|
||||
self.key - the name of this command ('mycommand')
|
||||
self.aliases - the aliases of this cmd ('mycmd','myc')
|
||||
self.locks - lock string for this command ("cmd:all()")
|
||||
self.help_category - overall category of command ("General")
|
||||
|
||||
# added at run-time by cmdhandler:
|
||||
|
||||
# added at run-time by cmdhandler:
|
||||
|
||||
self.caller - the object calling this command
|
||||
self.cmdstring - the actual command name used to call this
|
||||
|
|
@ -67,10 +67,10 @@ class Command(BaseCommand):
|
|||
for example)
|
||||
self.args - the raw input; everything following self.cmdstring.
|
||||
self.cmdset - the cmdset from which this command was picked. Not
|
||||
often used (useful for commands like 'help' or to
|
||||
often used (useful for commands like 'help' or to
|
||||
list all available commands etc)
|
||||
self.obj - the object on which this command was defined. It is often
|
||||
the same as self.caller.
|
||||
the same as self.caller.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
|
@ -78,13 +78,13 @@ class Command(BaseCommand):
|
|||
"""
|
||||
This is the hook function that actually does all the work. It is called
|
||||
by the cmdhandler right after self.parser() finishes, and so has access
|
||||
to all the variables defined therein.
|
||||
to all the variables defined therein.
|
||||
"""
|
||||
self.caller.msg("Command called!")
|
||||
|
||||
def at_post_cmd(self):
|
||||
"""
|
||||
This hook is called after self.func().
|
||||
This hook is called after self.func().
|
||||
"""
|
||||
pass
|
||||
|
||||
|
|
@ -101,32 +101,32 @@ class MuxCommand(default_cmd.MuxCommand):
|
|||
name[ with several words][/switch[/switch..]] arg1[,arg2,...] [[=|,] arg[,..]]
|
||||
|
||||
The 'name[ with several words]' part is already dealt with by the
|
||||
cmdhandler at this point, and stored in self.cmdname. The rest is stored
|
||||
in self.args.
|
||||
cmdhandler at this point, and stored in self.cmdname. The rest is stored
|
||||
in self.args.
|
||||
|
||||
The MuxCommand parser breaks self.args into its constituents and stores them in the
|
||||
following variables:
|
||||
The MuxCommand parser breaks self.args into its constituents and stores them in the
|
||||
following variables:
|
||||
self.switches = optional list of /switches (without the /)
|
||||
self.raw = This is the raw argument input, including switches
|
||||
self.args = This is re-defined to be everything *except* the switches
|
||||
self.lhs = Everything to the left of = (lhs:'left-hand side'). If
|
||||
self.lhs = Everything to the left of = (lhs:'left-hand side'). If
|
||||
no = is found, this is identical to self.args.
|
||||
self.rhs: Everything to the right of = (rhs:'right-hand side').
|
||||
self.rhs: Everything to the right of = (rhs:'right-hand side').
|
||||
If no '=' is found, this is None.
|
||||
self.lhslist - self.lhs split into a list by comma
|
||||
self.rhslist - list of self.rhs split into a list by comma
|
||||
self.arglist = list of space-separated args (including '=' if it exists)
|
||||
|
||||
All args and list members are stripped of excess whitespace around the
|
||||
strings, but case is preserved.
|
||||
All args and list members are stripped of excess whitespace around the
|
||||
strings, but case is preserved.
|
||||
"""
|
||||
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
This is the hook function that actually does all the work. It is called
|
||||
by the cmdhandler right after self.parser() finishes, and so has access
|
||||
to all the variables defined therein.
|
||||
"""
|
||||
# this can be removed in your child class, it's just
|
||||
to all the variables defined therein.
|
||||
"""
|
||||
# this can be removed in your child class, it's just
|
||||
# printing the ingoing variables as a demo.
|
||||
super(MuxCommand, self).func()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue