From 790f8407152c093e260badf98bb09a9faf494e2d Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 31 May 2011 15:33:37 +0000 Subject: [PATCH] Added the @tunnel command as a wrapper for @dig, for easy building in commonly used directions (n,sw, up, down, in, out etc) --- src/commands/connection_screen.py | 2 +- src/commands/default/building.py | 81 +++++++++++++++++++++++++- src/commands/default/cmdset_default.py | 1 + 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/commands/connection_screen.py b/src/commands/connection_screen.py index 32f532dc55..59a96aaa75 100644 --- a/src/commands/connection_screen.py +++ b/src/commands/connection_screen.py @@ -14,5 +14,5 @@ DEFAULT_SCREEN = \ If you need to create an account, type (without the <>'s): {wcreate \"\" {n - Enter {whelp{n for more info. {wlook{n will re-load this screen. + Enter {whelp{n for more info. {wlook{n will re-show this screen. {b=============================================================={n""" % utils.get_evennia_version() diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 54c45b5d24..83e475efa0 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -558,7 +558,7 @@ class CmdDig(ObjManipCommand): [, exit_to_here[;alias][:typeclass]] Switches: - teleport - move yourself to the new room + tel or teleport - move yourself to the new room Examples: @dig kitchen = north;n, south;s @@ -664,10 +664,87 @@ class CmdDig(ObjManipCommand): exit_back_string = exit_back_string % (new_room.name, location.name, new_back_exit, new_back_exit.dbref, alias_string) caller.msg("%s%s%s" % (room_string, exit_to_string, exit_back_string)) - if new_room and 'teleport' in self.switches: + if new_room and ('teleport' in self.switches or "tel" in self.switches): caller.move_to(new_room) +class CmdTunnel(MuxCommand): + """ + tunnel in often-used directions + Usage: + @tunnel[/switch] [= roomname[;alias;alias;...][:typeclass]] + + Switches: + oneway - do not create an exit back to the current location + tel - teleport to the newly created room + + Example: + @tunnel n + @tunnel n = house;mike's place;green building + + This is a simple way to build using pre-defined directions: + {wn,ne,e,se,s,sw,w,nw{n (north, northeast etc) + {wu,d{n (up and down) + {wi,o{n (in and out) + The full names (north, in, southwest, etc) will always be put as + main name for the exit, using the abbreviation as an alias (so an + exit will always be able to be used with both "north" as well as + "n" for example). Opposite directions will automatically be + created back from the new room unless the /oneway switch is given. + For more flexibility and power in creating rooms, use @dig. + """ + + key = "@tunnel" + aliases = ["@tun"] + locks = "cmd: perm(tunnel) or perm(Builders)" + help_category = "Building" + + # store the direction, full name and its opposite + directions = {"n" : ("north", "s"), + "ne": ("northeast", "sw"), + "e" : ("east", "w"), + "se": ("southeast", "nw"), + "s" : ("south", "n"), + "sw": ("southwest", "ne"), + "w" : ("west", "e"), + "nw": ("northwest", "se"), + "u" : ("up", "d"), + "d" : ("down", "u"), + "i" : ("in", "o"), + "o" : ("out", "i")} + + def func(self): + "Implements the tunnel command" + + if not self.args or not self.lhs: + string = "Usage: @tunnel[/switch] [= roomname[;alias;alias;...][:typeclass]]" + self.caller.msg(string) + return + if self.lhs not in self.directions: + string = "@tunnel can only understand the following directions: %s." % ",".join(sorted(self.directions.keys())) + string += "\n(use @dig for more freedom)" + self.caller.msg(string) + return + # retrieve all input and parse it + exitshort = self.lhs + exitname, backshort = self.directions[exitshort] + backname = self.directions[backshort][0] + + roomname = "Some place" + if self.rhs: + roomname = self.rhs # this may include aliases; that's fine. + + telswitch = "" + if "tel" in self.switches: + telswitch = "/teleport" + backstring = "" + if not "oneway" in self.switches: + backstring = ", %s;%s" % (backname, backshort) + + # build the string we will use to call @dig + digstring = "@dig%s %s = %s;%s%s" % (telswitch, roomname, exitname, exitshort, backstring) + self.caller.execute_cmd(digstring) + class CmdLink(MuxCommand): """ @link - connect objects diff --git a/src/commands/default/cmdset_default.py b/src/commands/default/cmdset_default.py index 73fcc7298f..54e107cbed 100644 --- a/src/commands/default/cmdset_default.py +++ b/src/commands/default/cmdset_default.py @@ -70,6 +70,7 @@ class DefaultCmdSet(CmdSet): self.add(building.CmdUnLink()) self.add(building.CmdCreate()) self.add(building.CmdDig()) + self.add(building.CmdTunnel()) self.add(building.CmdDestroy()) self.add(building.CmdExamine()) self.add(building.CmdTypeclass())