Added the @tunnel command as a wrapper for @dig, for easy building in commonly used directions (n,sw, up, down, in, out etc)

This commit is contained in:
Griatch 2011-05-31 15:33:37 +00:00
parent f3776d1e08
commit 790f840715
3 changed files with 81 additions and 3 deletions

View file

@ -14,5 +14,5 @@ DEFAULT_SCREEN = \
If you need to create an account, type (without the <>'s):
{wcreate \"<username>\" <email> <password>{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()

View file

@ -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] <direction> [= 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] <direction> [= 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

View file

@ -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())