[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Problem with AAMapper plugin
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Problem with AAMapper plugin

You need to log onto the forum to reply or create new threads.

  [Refresh] Refresh page


Posted by Branagh   (3 posts)  [Biography] bio
Date Tue 22 May 2018 09:24 AM (UTC)
Message
Hi,
I'm using this automapper plugin for Alter Aeon (I didn't write it):
https://github.com/Neurrone/Mushclient-Plugins/blob/master/AAMapper/worlds/plugins/AAMapper.xml

The mapper find function doesn't create clickable hyperlinks properly. Can anyone show me how to fix this?

For example, I type mapper find hall and get this output:

The multi-purpose hall (5035.80784) - 2 rooms away
The multi-purpose hall (5035.80786) - 3 rooms away

If I click on either hyperlink I get this message:
Room uids must have the format area_num.room_num

So I deleted this:
local areanum, roomnum = parseRoomUid(wantedUid)
if not (roomnum and areanum) then
mapper.mapprint ("Room uids must have the format area_num.room_num")
return
end

Now when I click I get this message:
Room 7CA48639C596B77C24782B16950D702F not found in database.

If I type mapper next, mapper 1 or mapper 2 it will speedwalk me to the correct room.
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 22 May 2018 09:07 PM (UTC)
Message
I tried to test on Alter Aeon but can't get the mapper to work at all. Is there some trick to activating it?

I don't see MUSHclient listed on their page of clients that they recommend.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Branagh   (3 posts)  [Biography] bio
Date Reply #2 on Tue 22 May 2018 10:28 PM (UTC)
Message
Sorry, I forgot about some stuff. Didn't mean to waste your time.
You also need this for the mapper to work:
https://github.com/Neurrone/Mushclient-Plugins/blob/master/AAUtilities/worlds/plugins/AAUtilities.xml
To turn on kxwt (sends the out of band data) type 'set kxwt on' at the welcome screen or 'set ctrigger on' inside the game.
In line 984 of the mapper replace
db = assert (sqlite3.open(DATABASE_PATH))
with: db = assert (sqlite3.open(GetInfo (66) .. Trim (WorldAddress ()) .. "_" .. WorldPort () .. ".db"))
or just put " " around DATABASE_PATH
Room names are not part of kxwt and it sometimes matches on the wrong line. If you type 'show room' when you are in a room with an obviously wrong room name, it will fix it.
I hope that's everything.
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 23 May 2018 03:21 AM (UTC)

Amended on Wed 23 May 2018 04:18 AM (UTC) by Nick Gammon

Message
I worked out the other stuff except typing "set kxwt on" at the logon screen (I guessed there would be some command to turn on that stuff).

It seems the problem is in the function mapper.do_hyperlink in the file AAMapper.xml. Undo the change you made above, and just comment out this entire function, like this:


--[=[   -- <------------------ HERE
mapper.do_hyperlink = function(uid)
  goToRoom(uid)
  -- if the same room appears multiple times in recentResultUids, they should be next to each other (thanks to SQL sorting)
  -- hence, we should ensure that we increment nextResultIndex far enough to skip duplicates of the current room
  for i,v in ipairs(recentResultUids) do
    if uid == v then
      nextResultIndex = i + 1
      -- do not break early
    end
  end
  -- if the user clicks on a hyperlink for a room in e.g, a past query, and if the most recent query does not contain this room, nextResultIndex is left untouched
end
--]=]   -- <------------------ AND HERE


I don't know what the author was thinking of by doing this. The link generated from a mapper find is a hash (for example 7CA48639C596B77C24782B16950D702F from your original post). This is a hash of the current position you are, and where you might go. It doesn't make sense to bypass that because the speedwalk depends on where you are. Or if it does make sense they didn't implement it correctly. The uid beinh passed down to goToRoom is the hash, whereas that is expecting something like 5035.80784. Not being the author of that plugin I don't know exactly how to fix it properly, but commenting out the above function certainly lets me use those hyperlinks.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 23 May 2018 06:03 AM (UTC)
Message
The reason that links have to expire (which the code added to AAMapper seems to try to circumvent) is that the mapper, when asked to find certain rooms (eg. matching a word) finds such rooms, and also saves in a table the speedwalk to that room. The table is then sorted in shortest-to-longest order and presented to the user. Internally a hash is generated which is a combination of the current room and the target room (that is the key for each entry). The value for each entry is the speedwalk.

This hash is presented in the hyperlink. Then if you choose to go to a certain room (eg. the local baker) then speedwalk can then be directly looked up. However that speedwalk is meaningless if you have moved, and thus the hashes expire if you change rooms.

Now the author of the mapper seems to have decided to remove that restriction, however as far as I can see, not successfully. You could conceivably store the destination room ID (and not a hash) and then re-compute the speedwalk to that place.

Perhaps they made a custom mapper.lua file which does exactly that. I don't have enough information to know whether or not that is the case. If it is, well done! It's a nice idea.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Branagh   (3 posts)  [Biography] bio
Date Reply #5 on Wed 23 May 2018 07:41 AM (UTC)
Message
Thank you. It was frustrating not being able to click on the links. When I try to fix plugins myself I usually end up making nothing work.
I noticed it only works for mapper find and not mapper notes list though. Mapper notes list now gives 'Hyperlink is no longer valid, as you have moved.' message even when you haven't moved yet. Mapper next and mapper <resultnumber> work for both even if you have changed rooms so it must store the destination ID for those?
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Thu 24 May 2018 06:56 AM (UTC)
Message
OK, well we need to conditionally call this function. Try replacing the function mapper.do_hyperlink with this:


original_do_hyperlink = mapper.do_hyperlink  -- save original function
mapper.do_hyperlink = function(uid)
  if string.match (uid, "^%x+$") then  -- if a hash then use the original
    original_do_hyperlink (uid)
    return
  end -- if
  goToRoom(uid)
  -- if the same room appears multiple times in recentResultUids, they should be next to each other (thanks to SQL sorting)
  -- hence, we should ensure that we increment nextResultIndex far enough to skip duplicates of the current room
  for i,v in ipairs(recentResultUids) do
    if uid == v then
      nextResultIndex = i + 1
      -- do not break early
    end
  end
  -- if the user clicks on a hyperlink for a room in e.g, a past query, and if the most recent query does not contain this room, nextResultIndex is left untouched
end


What that does is first save the original function, and then check what sort of UID we get, and if it is a hex one call the original do_hyperlink (which now works) otherwise it does what it used to do.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


306 views.

You need to log onto the forum to reply or create new threads.

  [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]