<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, September 22, 2002, 1:49 PM -->
<!-- MuClient version 3.26 -->

<!-- Plugin "MUSH_teleport" generated by Plugin Wizard -->

<!--
If your MUD uses a different system of teleporting (eg. goto vnum) change the line that does a '@teleport dbref' to 'goto vnum'
-->

<muclient>
<plugin
   name="MUSH_teleport"
   author="Nick Gammon"
   id="f210c046e780c0d769eaf0fa"
   language="VBscript"
   purpose="Lets you teleport to a list of rooms that you can set up"
   save_state="y"
   date_written="2002-09-22 13:43:36"
   requires="3.25"
   version="1.2"
   >
<description trim="y">
<![CDATA[
This lets you maintain a list of destinations of interest to teleport to and go to them by name. This is intended for MUSHes but could be adapted for other MUD types.

Usage
-----

addtel name room_number

   eg.  addtel town_square 1862

teleport name

   eg.  teleport town_square

teleport  <- on its own lists all available destinations


MUSH_teleport:help  <- this help screen
]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.vbs"/>

<!--  Aliases  -->

<aliases>
  <alias
   name="AddTeleport"
   script="OnAddTeleport"
   match="^addtel( .*?)?( .*?)?$"
   enabled="y"
   regexp="y"
  >
  </alias>
  <alias
   name="Teleport"
   script="OnTeleport"
   match="^teleport(.*)$"
   enabled="y"
   regexp="y"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
' ---------------------------------------------------------
' Teleport to a room.
'
' ---------------------------------------------------------
sub OnTeleport (thename, theoutput, thewildcards)

dim sDestination
dim sRoomList
dim sHelp
dim iSubscript
dim iRoom

sDestination = Trim (thewildcards (1))

' if nothing entered echo possible destinations
if sDestination = "" then
  world.note "-------- TELEPORT destinations ----------"	

  ' find list of all variables
  sRoomList = world.GetVariableList

  if not IsEmpty (sRoomList) then

    ' loop through each variable, and add to help if it starts with "teleport_"
    for iSubscript = lbound (sRoomList) to ubound (sRoomList)
       if Left (sRoomList (iSubscript), 9) = "teleport_" then
          if sHelp <> "" then
             sHelp = sHelp & ", "
          end if
          sHelp = sHelp & Mid (sRoomList (iSubscript), 10)
       end if   ' variable starts with "teleport_"
    next        ' loop through sRoomList

  end if	' having at least one room

  ' if no destinations found, tell them
  if sHelp = "" then
    sHelp = "<no rooms in teleport list>"
  end if    ' no destinations found in list
  world.note sHelp
  exit sub

end if    ' no destination supplied

' get contents of the destination variable 
iRoom = world.GetVariable ("teleport_" & lCase (sDestination))

' if not found, or invalid name, that isn't in the list
if IsEmpty (iRoom) or IsNull (iRoom) then
  world.note "******** Destination " & sDestination & " unknown *********"
  exit sub
end if

world.note "------> Teleporting to " & sDestination
world.send "@teleport #" & cstr (iRoom)

end sub

' ---------------------------------------------------------
'  Add a room to the teleport list
'
'  eg.  ADD_TELEPORT  dungeon 1234
'
' ---------------------------------------------------------
sub OnAddTeleport (thename, theoutput, thewildcards)

dim sDestination
dim iRoom
dim iStatus
dim sCurrentLocation

' wildcard one is the destination
sDestination = Trim (thewildcards (1))

' if nothing entered tell them command syntax
if sDestination = "" then
  world.note "Syntax: addtel name dbref"
  world.note "    eg. addtel LandingBay 4421"
  exit sub
end if

' wildcard 2 is the room to go to
iRoom= Trim (thewildcards (2))

if not IsNumeric (iRoom) then
  world.note "Room to teleport to must be a number, you entered: " & iRoom
  exit sub
end if

' add room and destination location to variable list
iStatus = world.SetVariable ("teleport_" & sDestination, iRoom)

if iStatus <> 0 then
  world.note "Room name must be alphabetic, you entered: " & sDestination
  exit sub
end if

world.note "Teleport location " & sDestination & "(#" _
           & iRoom & ") added to teleport list"

end sub


]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="MUSH_teleport:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  World.Note World.GetPluginInfo (World.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>
