Posted by
| Nick Gammon
Australia (23,132 posts) Bio
Forum Administrator |
Message
| This is somewhat of a hack, but this appears to work:
|
To save and install the Alternative_Mapper plugin do this:
- Copy between the lines below (to the Clipboard)
- Open a text editor (such as Notepad) and paste the plugin into it
- Save to disk on your PC, preferably in your plugins directory, as Alternative_Mapper.xml
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file Alternative_Mapper.xml (which you just saved in step 3) as a plugin
- Click "Close"
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!DOCTYPE muclient [
<!ENTITY show_vnums "true" >
<!ENTITY show_timing "false" >
<!ENTITY show_completed "true" >
<!ENTITY show_database_mods "false" >
<!ENTITY show_other_areas "false" >
<!ENTITY show_up_down "false" >
<!ENTITY speedwalk_prefix "run" >
]>
<muclient>
<plugin
name="Alternative_Mapper"
author="Multiple"
id="83fdb6092b08fb95e4f85a2f"
language="Lua"
purpose="Allows you to modify the Aardwolf mapper"
save_state="y"
date_written="2019-11-29 07:01:18"
requires="4.73"
version="1.0"
>
<description trim="y">
<![CDATA[
AUTOMATIC MAPPER by Fiendish
** This is a very improved GMCP version of the original ATCP mapper by Nick Gammon.
** Some GMCP specific code added by Lasher.
** A few features contributed by Spartacus.
** Many major improvements made to the original design by Fiendish.
]]>
</description>
</plugin>
<script>
local show_vnums = &show_vnums;
local show_timing = &show_timing;
local show_completed = &show_completed;
local show_database_mods = &show_database_mods;
local show_other_areas = &show_other_areas;
local show_up_down = &show_up_down;
local speedwalk_prefix = "&speedwalk_prefix;"
<![CDATA[
-- helper import function
function ImportFromPlugin (what)
local xml = string.match (plugin, string.format ('<%s>.*</%s>', what, what))
assert (xml, "Could not find the " .. what)
ImportXML (xml)
xml = nil -- free memory
end -- ImportFromPlugin
-- read the entire plugin into memory
f = assert (io.open (GetInfo (60) .. "aard_GMCP_mapper.xml", "r")) -- open it
plugin = f:read ("*a") -- read all of it
f:close () -- close it
-- get the original timers, triggers, aliases
ImportFromPlugin 'timers'
ImportFromPlugin 'triggers'
ImportFromPlugin 'aliases'
-- get the script
script = string.match (plugin, '<script>(.*)</script>')
assert (script, "Could not find the script")
plugin = nil -- free memory
-- pull out the CDATA stuff from within the script
script = string.match (script, '<!%[CDATA%[(.*)%]%]>')
assert (script, "Could not find the internal script")
-- load the script
assert (loadstring (script)) ()
script = nil -- free memory
-- replace functions here
function map_find (name, line, wildcards)
local rooms = {}
local count = 0
-- find matching rooms using exact match
local name = wildcards[1]
if string.sub(wildcards[1],1,1) == "\"" and string.sub(wildcards[1],-1) == "\"" then
name = string.sub(wildcards[1],2,-2)
end
for row in dbnrowsWRAPPER(string.format ("SELECT uid, name FROM rooms WHERE rooms.name = %s", fixsql (name))) do
table.insert(rooms, {uid=row.uid, reason=true})
count = count + 1
end -- finding room
-- see if nearby
mapper.find (name,
rooms, -- function
50,
show_vnums, -- show vnum?
count, -- how many to expect
false, -- don't auto-walk
nil,
quick_mode
)
end -- map_find
]]>
</script>
</muclient>
What this does is read in the Aardwolf mapper as a text file, import its triggers, timers and aliases, and then import its script file. This should now be effectively a copy of the original plugin (aard_GMCP_mapper.xml).
Now you have the plugin in a script space you control, you can replace functions in it as in the example map_find function above.
So:
- Remove aard_GMCP_mapper.xml from your plugins list
- Place this plugin there instead
- Save the world file and restart the client
Now any future fixes should be automatically implemented, except to the function map_find of course.
An alternative approach for this particular problem would be to ask Fiendish to add a configuration option (like the other ones at the start of the plugin) to make the mapper find not default to wildcards. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|