| Message
| Well, this is the version I have on disk, it looks more extensive than the earlier post. I can't say if I know whether it works, I forgot I had it ...
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, March 22, 2004, 4:43 PM -->
<!-- MuClient version 3.47 -->
<!-- Plugin "Automap" generated by Plugin Wizard -->
<muclient>
<plugin
name="Automap"
author="Nick Gammon"
id="23a544e6b6eeb7ea26c29b7d"
language="VBscript"
purpose="Creates speedwalks from one checkpoint to another one"
save_state="y"
date_written="2004-03-22 16:38:10"
requires="3.47"
version="1.2"
>
<description trim="y">
<![CDATA[
cp [nr] - add a checkpoint - optional "nr" argument specifies "no return"
cl - list checkpoints from this location
cl x - lists checkpoints, filtered by x (eg. cl tavern)
cg x - go to checkpoint x (eg. cg 5)
cc - clear current speedwalk - start new checkpoint
cr x - manually define room name (eg. cr Outside East Gate)
ci - checkpoint info - lists all known paths in the database
cdel x - checkpoint delete - deletes a path or node identified in the "ci" list
cdel all - deletes all map info
cn - go to last node (ie. one we just left)
csave - save the database, in case of a crash
chelp - this description
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.vbs"/>
<!-- Triggers -->
<!-- red = 9, green = 10 -->
<triggers>
<trigger
back_colour="8"
bold="y"
enabled="y"
match="*"
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
sequence="100"
text_colour="10"
script="OnRoomFromFirstStyle"
>
</trigger>
<trigger
enabled="y"
match="<*>*"
script="OnGetRoomFromPrompt"
sequence="100"
>
</trigger>
<trigger
back_colour="8"
bold="y"
enabled="y"
match="^(The reddish sun sets past the horizon\.|The sun slowly disappears in the west\.|The sun's radiance dims as it sinks in the sky\.|The sky turns a reddish orange as the sun ends its journey\.|You are carrying\:)$"
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
regexp="y"
sequence="90"
text_colour="9"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
script="OnClearcheckpoint"
match="cc"
echo_alias="y"
enabled="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpointlist"
match="^cl( .*)?$"
echo_alias="y"
enabled="y"
regexp="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpointinfo"
match="ci"
echo_alias="y"
enabled="y"
sequence="100"
>
</alias>
<alias
match="csave"
enabled="y"
send_to="12"
sequence="100"
>
<send>SaveState
ColourNote "white", "green", "Database saved"</send>
</alias>
<alias
script="OnCheckpointGotoNode"
match="cn"
echo_alias="y"
enabled="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpointDelete"
match="cdel *"
echo_alias="y"
enabled="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpoint"
match="^cp( nr)?$"
echo_alias="y"
enabled="y"
regexp="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpointRoom"
match="cr *"
echo_alias="y"
enabled="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpointgoto"
match="cg *"
echo_alias="y"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
'----------------------------------------------------------
' Load mapping array
'----------------------------------------------------------
Sub OnPluginInstall
ArrayCreate "map"
ArrayImport "map", GetVariable ("map"), ","
ArrayCreate "" ' work array
ArrayCreate "dest" ' destinations array
ArrayCreate "cl" ' current listed destinations array
ArrayCreate "cin" ' ci - nodes
ArrayCreate "cip" ' ci - paths
SetVariable "known_room", ""
SetVariable "known_checkpoint", ""
SetVariable "known_mapstring", ""
SetVariable "clroom", ""
'
' turn auto-mapping on
'
EnableMapping vbTrue
End Sub
'----------------------------------------------------------
' The plugin is saving its state
'----------------------------------------------------------
sub OnPluginSaveState
'
' Save mapping array
'
SetVariable "map", ArrayExport ("map", ",")
end sub
'----------------------------------------------------------
' helper routine to add a new path to the array
'----------------------------------------------------------
Sub AddPath (from_location, to_location, speedwalk)
dim currspeedwalk, currpath, newpath
newpath = EvaluateSpeedwalk (RemoveBacktracks (speedwalk))
ArrayClear "" ' get rid of previous stuff
'
' get current entries into work array
'
ArrayImport "", ArrayGet ("map", from_location), ","
'
' see what the current path there is
'
currspeedwalk = RemoveBacktracks (ArrayGet ("", to_location))
If currspeedwalk <> "" Then
currpath = EvaluateSpeedwalk (currspeedwalk)
If Len (newpath) > Len (currpath) Then
ColourNote "white", "red", "New path is: " & RemoveBacktracks (speedwalk)
ColourNote "white", "red", "Old path is: " & currspeedwalk
ColourNote "white", "red", "Retaining older, shorter, path."
Exit Sub
End If ' new path longer
End If ' have an old path
'
' note path from last checkpoint
'
ArraySet "", to_location, speedwalk
ColourNote "white", "blue", "Path from '[" & _
from_location & "] to [" & _
to_location & "] noted as " & _
speedwalk
'
' put back new destinations
'
ArraySet "map", from_location, ArrayExport ("", ",")
End Sub ' AddPath
'----------------------------------------------------------
' Make a checkpoint (node)
'----------------------------------------------------------
Sub OnCheckpoint (name, line, wildcards)
Dim room, checkpoint, mapstring
'
' get into variables to save time and confusion
'
room = trim (GetVariable ("room"))
'
' if they stumbled across a known node, the "room change" routine
' clears the map info, however we needed that to checkpoint the room
'
if room = GetVariable ("known_room") Then
checkpoint = trim (GetVariable ("known_checkpoint"))
mapstring = GetVariable ("known_mapstring")
Else
checkpoint = trim (GetVariable ("checkpoint"))
mapstring = GetMappingString
End If
If Mapping Then
If checkpoint <> "" And _
room <> "" And _
mapstring <> "" Then
AddPath checkpoint, room, mapstring
'
' now add reverse path - if wanted
'
If trim (wildcards (1)) <> "nr" Then
AddPath room, checkpoint, "{auto}" & ReverseSpeedwalk (mapstring)
End If
End If ' already have a checkpoint
'
' note new checkpoint
'
OnClearcheckpoint "", "", ""
Else
ColourNote "white", "red", "Auto-mapper not active"
End If ' mapping
End Sub ' OnCheckpoint
'----------------------------------------------------------
' Clear a checkpoint
'----------------------------------------------------------
Sub OnClearcheckpoint (name, line, wildcards)
'
' clear checkpoint (start from here)
'
SetVariable "checkpoint", GetVariable ("room")
'
' start mapping again from here
'
DeleteAllMapItems
ColourNote "white", "blue", "New checkpoint started at: " _
& GetVariable ("room")
End Sub ' OnClearcheckpoint
'----------------------------------------------------------
' Add destinations to "dest" array from location "from"
'----------------------------------------------------------
Sub GetDestinations (orig, from, speedwalk, indent, level)
dim d, k, existing, path
'debug Note indent & "finding destinations from " & from & " prefix " & speedwalk
ArrayCreate level
ArrayClear level ' get rid of previous stuff
ArrayImport level, ArrayGet ("map", from), ","
'
' check each one
'
d = ArrayListKeys (level)
If IsEmpty (d) Then Exit Sub
For Each k In d
if k <> orig then
path = ArrayGet (level, k)
existing = ArrayGet ("dest", k)
'debug Note indent & "considering " & k & " path " & path
'debug Note indent & "existing = " & existing
If (len (EvaluateSpeedWalk (RemoveBacktracks (existing))) > _
len (EvaluateSpeedWalk (RemoveBacktracks (speedwalk & path)))) Or _
(existing = "") Then
ArraySet "dest", k, speedwalk & path
'debug Note indent & "** addding destination " & k & " path = " & speedwalk & path
'
' recurse to get destinations from *this* destination
'
If k <> from Then
'debug Note indent & "recursing to find walks from " & k & " with prefix " & speedwalk & path
GetDestinations orig, k, speedwalk & path, indent & " ", level + 1
End If
End If ' not already having a path there
End If ' not going to where we started
Next ' end of doing each destination
End Sub ' GetDestinations
'----------------------------------------------------------
' cl - List available checkpoints
'
' You can specify a filter, eg. cl tavern
'----------------------------------------------------------
Sub OnCheckpointlist (name, line, wildcards)
Dim room, destinations, count, k, path, filter
filter = trim (Lcase (wildcards (1)))
room = trim (GetVariable ("room"))
SetVariable "clroom", room ' note what room we were in
count = 0
ColourNote "white", "blue", "Current room believed to be [" & _
room & "]"
'
' get current entries into work array
'
ArrayClear "dest"
GetDestinations room, room, "", "", 1
ArrayClear "cl"
destinations = ArrayListKeys ("dest")
If Not IsEmpty (destinations) Then
For Each k In destinations
If (filter = "") or (instr (lcase (k), filter) <> 0) Then
count = count + 1
path = RemoveBacktracks (ArrayGet ("dest", k))
world.ColourNote "white", "blue", " " & _
CStr (count) & ": " & k & " (" & path & ")"
ArraySet "cl", count, path
End If
Next
if (count = 0) and (filter <> "") then
ColourNote "white", "blue", "No destinations matching filter: " & filter
end if
Else
ColourNote "white", "blue", "No known destinations from here"
If GetVariable ("checkpoint") <> "" And _
trim (GetMappingString) <> "" Then
ColourNote "white", "blue", "You were last at [" & _
GetVariable ("checkpoint") & "] (" & _
trim (ReverseSpeedwalk (GetMappingString)) & ")"
ColourNote "white", "blue", "Type 'cn' to go there"
End If
End If
End Sub ' OnCheckpointlist
'----------------------------------------------------------
' go to a checkpoint
'----------------------------------------------------------
Sub OnCheckpointgoto (name, line, wildcards)
Dim room, destinations, which
if ArraySize ("cl") = 0 then
ColourNote "white", "red", "You have not done a 'cl' or there were no rooms listed"
Exit Sub
end if
room = trim (GetVariable ("room"))
if room <> GetVariable ("clroom") then
ColourNote "white", "red", "You have changed rooms since doing a 'cl'"
ColourNote "white", "red", "You were in [" & GetVariable ("clroom") & "]"
ColourNote "white", "red", "You are now in [" & room & "]"
Exit Sub
end if
which = CInt (wildcards (1)) ' which choice
if not ArrayKeyExists ("cl", which) then
ColourNote "white", "red", "Destination " & which & _
" was not on the list"
exit sub
end if
'
' go there :)
'
Send EvaluateSpeedwalk (RemoveBacktracks (ArrayGet ("cl", which)))
End Sub ' OnCheckpointgoto
'----------------------------------------------------------
' Show node info
'----------------------------------------------------------
Sub OnCheckpointinfo (name, line, wildcards)
Dim nodes, k, dests, j, nodenum, destnum
nodenum = 0
destnum = 0
ArrayClear "cin" ' ci - nodes
ArrayClear "cip" ' ci - paths
nodes = ArrayListKeys ("map")
If IsEmpty (nodes) Then
ColourNote "white", "blue", "No mapping points known."
Else
For Each k In nodes
nodenum = nodenum + 1
ArraySet "cin", "N" & nodenum, k
ColourNote "white", "darkgreen", "N" & Cstr (nodenum) & ". " & k
'
' Get destinations from this node
'
ArrayClear "dest"
ArrayImport "dest", ArrayGet ("map", k), ","
dests = ArrayListKeys ("dest")
If Not IsEmpty (dests) Then
For Each j in dests
destnum = destnum + 1
ArrayClear ""
ArraySet "", "node", k
ArraySet "", "dest", j
' save both node and path here
ArraySet "cip", "P" & destnum, ArrayExport ("", ",")
ColourNote "limegreen", "black", " P" & _
CStr (destnum) & ". " & _
j & " = " & ArrayGet ("dest", j)
Next ' dest
End If
Next ' next node
End If
End Sub ' OnCheckpointinfo
'----------------------------------------------------------
' delete a checkpoint node or path
'----------------------------------------------------------
Sub OnCheckpointDelete (name, line, wildcards)
dim which, k, node, nodes
which = UCase (trim (wildcards (1)))
if which = "ALL" then
ArrayClear "map"
ArrayClear "cin"
ArrayClear "cip"
ArrayClear "cl"
ColourNote "white", "red", "ALL mapping points deleted."
OnClearcheckpoint "", "", ""
SetVariable "known_room", ""
SetVariable "known_checkpoint", ""
SetVariable "known_mapstring", ""
Exit Sub
end if
If left (which, 1) = "N" Then ' delete node
If not ArrayKeyExists ("cin", which) Then
ColourNote "white", "red", "Node number " & which & " does not exist"
Exit Sub
End If
node = ArrayGet ("cin", which)
if not ArrayKeyExists ("map", node) Then
ColourNote "white", "red", "Map checkpoint [" & node & "] does not exist"
Exit Sub
End If
ArrayDeleteKey "map", node
ColourNote "white", "blue", "Map checkpoint [" & node & "] deleted."
nodes = ArrayListKeys ("map")
If Not IsEmpty (nodes) Then
For Each k In nodes
'
' Get destinations from this node
'
ArrayClear ""
ArrayImport "", ArrayGet ("map", k), ","
If ArrayKeyExists ("", node) Then
ArrayDeleteKey "", node
ColourNote "white", "blue", "Path from [" & k & "] " & _
"to [" & node & "] deleted."
ArraySet "map", k, ArrayExport ("", ",")
End If
Next ' next node
End If
Exit Sub ' all done
End If ' deleting node
If left (which, 1) = "P" Then ' delete path
If not ArrayKeyExists ("cip", which) Then
ColourNote "white", "red", "Path number " & which & " does not exist"
Exit Sub
End If
'
' we stored the path as a node,destination pair
'
ArrayClear ""
ArrayImport "", ArrayGet ("cip", which), ","
node = ArrayGet ("", "node")
k = ArrayGet ("", "dest")
if not ArrayKeyExists ("map", node) Then
ColourNote "white", "red", "Map node [" & node & "] does not exist"
Exit Sub
End If
ArrayClear ""
ArrayImport "", ArrayGet ("map", node), ","
If ArrayKeyExists ("", k) Then
ArrayDeleteKey "", k
ColourNote "white", "blue", "Path from [" & node & "] " & _
"to [" & k & "] deleted."
ArraySet "map", node, ArrayExport ("", ",")
End If
Exit Sub ' all done
End If ' deleting node
ColourNote "white", "red", "Node number must start with N or P"
End Sub ' OnCheckpointDelete
'----------------------------------------------------------
' room has changed - are we at an existing node?
'----------------------------------------------------------
Sub RoomChanged
dim room
room = GetVariable ("room")
If ArrayKeyExists ("map", room) then
'
' we are at a known node - delete map items so
' we do not take some tortuous path from here to here
'
'
' first, however, save them in case they re-checkpoint this room
'
SetVariable "known_room", room
SetVariable "known_checkpoint", GetVariable ("checkpoint")
SetVariable "known_mapstring", GetMappingString
DeleteAllMapItems
ColourNote "white", "blue", "Now at known map node [" & room & "]"
SetVariable "checkpoint", room
End If
End Sub ' RoomChanged
dim roomnamestyle
roomnamestyle = 6
'----------------------------------------------------------
' deduce room name if on same line as prompt
'----------------------------------------------------------
Sub OnGetRoomFromPrompt (name, line, wildcards)
dim lines, styles, text
line = GetLinesInBufferCount
styles = GetLineInfo (line, 11)
'
' Should be 2 styles, the prompt and the room name
'
If Styles < roomnamestyle Then Exit Sub
'
' Room name is bold
'
If Not GetStyleInfo (line, roomnamestyle, 8) Then Exit Sub
'
' Room name is red text (2) or green text (3)
'
If Not GetStyleInfo (line, roomnamestyle, 14) = BoldColour (3) Then Exit Sub
'
' Room name is black background
'
If Not GetStyleInfo (line, roomnamestyle, 15) = NormalColour (1) Then Exit Sub
'
' Get name
'
SetVariable "room", GetStyleInfo (line, roomnamestyle, 1)
Call RoomChanged
End Sub ' OnGetRoomFromPrompt
'----------------------------------------------------------
' pull in room name from first style on line
'----------------------------------------------------------
Sub OnRoomFromFirstStyle (name, line, wildcards)
dim lines, styles
line = GetLinesInBufferCount
styles = GetLineInfo (line, 11)
'
' Get name
'
if (trim (GetStyleInfo (line, 1, 1)) <> "") and _
(GetStyleInfo (line, 1, 2) = 58) then
SetVariable "room", trim (GetStyleInfo (line, 1, 1))
Call RoomChanged
end if
End Sub ' OnRoomFromFirstStyle
'----------------------------------------------------------
' cr (room) - manually set room name
'----------------------------------------------------------
Sub OnCheckpointRoom (name, line, wildcards)
SetVariable "room", trim (wildcards (1))
ColourNote "white", "blue", "Room name set to " & GetVariable ("room")
Call RoomChanged
End Sub ' OnCheckpointRoom
'----------------------------------------------------------
' room change (from trigger)
'----------------------------------------------------------
Sub OnRoomChange (name, line, wildcards)
SetVariable "room", trim (wildcards (1))
Call RoomChanged
End Sub ' OnCheckpointRoom
'----------------------------------------------------------
' use mapper to backtrack to last node
'----------------------------------------------------------
Sub OnCheckpointGotoNode (name, line, wildcards)
dim mapstring
mapstring = trim (GetMappingString)
if mapstring = "" then
colournote "white", "red", "No map path available"
exit sub
end if
'
' try to go back
'
ColourNote "white", "blue", "Attempting to go to [" & _
GetVariable ("checkpoint") & "]"
Send EvaluateSpeedwalk (ReverseSpeedwalk (mapstring))
End Sub ' OnCheckpointGotoNode
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="chelp"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
world.Note world.GetPluginInfo (world.GetPluginID, 3)
End Sub
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|