Message
| Well, it is an interesting challenge, so I have made a start on it. This is very preliminary, but is a way of building up the data required for a more complex solution.
It seems to me that as you explore a place you have "important" points (ones you want to go back to), such as an inn, shop, central square, and other places, which are really just enroute points.
The plugin below is designed to allow you to collect "checkpoints" into an array (using the new array functions just released). Thus, you need to have the latest version, 3.46 to try it.
The general idea is to concentrate on mapping your way around, and then do this:
- Clear and mark a checkpoint: cc
- Wander around and find somewhere interesting (eg. a shop)
- Checkpoint this place: cp
- Go somewhere else (eg. a fountain)
- Checkpoint the new place: cp
Then when you want to go somewhere from a checkpointed place, type "cl" (checkpoint list), and you will see something like this:
Current room believed to be [Darkhaven Square]
1: Atop the Battlements (4n 4w u )
2: Darkhaven Academy (3e 3s 4w 4s 7e s d )
3: Entrance to the Academy ({auto} 3e s)
4: Inside the Northern Gate ({auto} 5n)
5: The Darkhaven Inn (2w s )
6: The Western Hall (w s )
7: Vertic Avenue ({auto} n)
Then type "cg x" where x is a number in the list (eg. cg 5) and it will generate the appropriate speedwalk.
The "{auto}" entries are generated automatically as reverse speedwalks, hoping that this will correctly take you back where you came from.
Now there is a fair bit that would need tweaking to get this perfect, for one thing I have custom coded how room names are recognised in SMAUG - a line containing bold text, red on black. Already I have found a problem with some system messages being in that colour, so I have put one in as a trigger with lower priority (so it fires first) and thus doesn't get considered as a room name.
Also, I found that I got room names at the end of prompts if you walked quickly, so I did another "prompt" trigger that does a GetStyleInfo to detect if the line consists of 2 styles, and the second one is bold red on black.
Another issue again is that it relies on speedwalks being generated, and it turns out you can't turn on automapping automatically, so this is added in version 3.47.
You also need to customise the "can't go in that direction" string for you own MUD, so the automapper recognises when you have done a false turn.
However as far as it goes, it is a nice way of quickly generating paths from one spot to another.
<?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.46"
version="1.0"
>
<description trim="y">
<![CDATA[
cp - add a checkpoint
cl - list checkpoints from this location
cg x - go to checkpoint x (eg. cg 5)
cc - clear current speedwalk - start new checkpoint
Automap:help - this description
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.vbs"/>
<!-- Triggers -->
<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"
send_to="9"
sequence="100"
text_colour="9"
variable="room"
>
<send>%1</send>
</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."
match_back_colour="y"
match_bold="y"
match_inverse="y"
match_italic="y"
match_text_colour="y"
sequence="90"
text_colour="9"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
script="OnClearcheckpoint"
match="cc"
enabled="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpointlist"
match="cl"
enabled="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpoint"
match="cp"
enabled="y"
sequence="100"
>
</alias>
<alias
script="OnCheckpointgoto"
match="cg *"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
'
' Load mapping array
'
Sub OnPluginInstall
ArrayCreate "map"
ArrayImport "map", GetVariable ("map"), ","
ArrayCreate "" ' work array
'
' turn auto-mapping on
'
' EnableMapping vbTrue ' (NOT IN THIS VERSION - use in version 3.47 up)
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 (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 = ArrayGet ("", to_location)
If currspeedwalk <> "" Then
currpath = EvaluateSpeedwalk (currspeedwalk)
If Len (newpath) > Len (currpath) Then
ColourNote "white", "red", "New path is: " & 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
Sub OnCheckpoint (name, line, wildcards)
Dim room, checkpoint, mapstring
'
' get into variables to save time and confusion
'
room = trim (GetVariable ("room"))
checkpoint = trim (GetVariable ("checkpoint"))
mapstring = GetMappingString
If Mapping Then
If checkpoint <> "" And _
room <> "" And _
mapstring <> "" Then
AddPath checkpoint, room, mapstring
'
' now add reverse path
'
AddPath room, checkpoint, "{auto}" & ReverseSpeedwalk (mapstring)
End If ' already have a checkpoint
'
' note new checkpoint
'
SetVariable "checkpoint", room
'
' start mapping again from here
'
DeleteAllMapItems
ColourNote "white", "blue", "New checkpoint started at: " _
& room
Else
ColourNote "white", "red", "Auto-mapper not active"
End If ' mapping
End Sub ' OnCheckpoint
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
Sub OnCheckpointlist (name, line, wildcards)
Dim room, destinations, count, k
room = trim (GetVariable ("room"))
count = 0
ColourNote "white", "blue", "Current room believed to be [" & _
room & "]"
'
' get current entries into work array
'
ArrayClear "" ' get rid of previous stuff
ArrayImport "", ArrayGet ("map", room), ","
destinations = ArrayListKeys ("")
If Not IsEmpty (destinations) Then
For Each k In destinations
count = count + 1
world.ColourNote "white", "blue", " " & _
CStr (count) & ": " & k & " (" & _
ArrayGet ("", k) & ")"
Next
Else
ColourNote "white", "blue", "No known destinations from here"
End If
End Sub ' OnCheckpointlist
Sub OnCheckpointgoto (name, line, wildcards)
Dim room, destinations, which
room = trim (GetVariable ("room"))
which = CInt (wildcards (1)) - 1 ' which choice, make zero-relative
'
' get current entries into work array
'
ArrayClear "" ' get rid of previous stuff
ArrayImport "", ArrayGet ("map", room), ","
destinations = ArrayListKeys ("")
If Not IsEmpty (destinations) Then
If which < lbound (destinations) or _
which > ubound (destinations) Then
ColourNote "white", "red", "Destination " & wildcards (1) & _
" out of range " & CStr (lbound (destinations) + 1) & " to " & _
CStr (ubound (destinations) + 1)
Exit Sub
End If
'
' go there :)
'
Send EvaluateSpeedwalk (ArrayGet ("", destinations (which)))
Else
ColourNote "white", "blue", "No known destinations from here"
End If
End Sub ' OnCheckpointgoto
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 <> 2 Then Exit Sub
'
' Room name is bold
'
If Not GetStyleInfo (line, 2, 8) Then Exit Sub
'
' Room name is red text
'
If Not GetStyleInfo (line, 2, 14) = BoldColour (2) Then Exit Sub
'
' Room name is black background
'
If Not GetStyleInfo (line, 2, 15) = NormalColour (1) Then Exit Sub
'
' Get name
'
SetVariable "room", GetStyleInfo (line, 2, 1)
End Sub ' OnGetRoomFromPrompt
]]>
</script>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="Automap:help"
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 |
|