Generic Mapping Script

All and any discussion and development of the Mudlet Mapper.
Post Reply
Jor'Mox
Posts: 1100
Joined: Wed Apr 03, 2013 2:19 am

Generic Mapping Script

Post by Jor'Mox » Thu Sep 01, 2016 6:10 pm

I made a mapping script for a MUD (DIKU style) I was playing, and I saw a request for one for a different MUD (New Worlds Ateraan), so I modified what I had to make a generic script that could be adapted for just about any MUD with a similar basic setup (room names and exits can be captured reasonably reliably, and movement uses basic commands with one move per command). As indicated in the help section at the top of the script, triggers need to be made to capture the relevant pieces for your specific MUD, and then raise the specified event. I hope some people find this useful. If there are any questions or problems, I'll see what I can do to help address them.

Download link: https://raw.githubusercontent.com/Mudle ... mapper.xml (script is included in Mudlet already as well)

Also, this script positions its mapper window using the Simple Window Manager Script (found here), but this should be able to be modified to use other GUI management systems as desired, by changing relevant lines in the config function.

As I have been asked this several times, the proper way to store the exits in the map.prompt.exits variable is as a string, with exit directions separated by any number of spaces and commas, and no extra words other than "and" (which is automatically removed). Ex: "north, south, west, up, and northwest" or "north south west up northwest".

Edit: Updated to handle in/out exit stubs properly, bypassing the bug in the Mudlet function setExitStub. Also added a "stretch_map" variable in the configs that lets you determine if the map will automatically reposition rooms if a new room would overlap with an existing one.

Edit: Updated to hopefully handle forced movement in known directions, via the "onForcedMove" event, which takes two arguments, the first being the direction you are being moved in, and the second (optional) telling it to force that movement to the front of the list of directions moved (use "true" as a string if this is needed). Note that this hasn't been tested, but given that it is basically just grabbing the exit it is given and putting it in the movement queue as if you had typed in the direction, I don't anticipate many problems.

Edit: At Vadi's suggestion, I created a proper package out of this, and wrote a single command you could put into Mudlet's command line to install it. There is a very basic set of triggers in place to help get things going, but the odds are low that they will work for your game without significant adjustment.

Edit: Updated to fix doors in non-cardinal and ordinal directions (i.e. up, down, in, and out)

Edit: Updated to switch to using UTF-8 to support international characters, also squashed a few bugs with help from Vadi.

Edit: Added an event that is raised when the map is moved, "onMoveMap", and an option to make the script search for a room match when 'look' is sent, which is search_on_look, which can be found with the rest of the configs for the script.
Code: [show] | [select all] lua
lua function downloaded_package(a,b) if not b:find("generic_mapper",1,true) then return end installPackage(b) os.remove(b) end registerAnonymousEventHandler("sysDownloadDone","downloaded_package") downloadFile(getMudletHomeDir().."/generic_mapper.mpackage","http://dslpnp.altervista.org/Generic_Mapper.mpackage")
Edit: Super experimental version of this script that tries to figure out your prompt for you, search for room names in a programatic way, and has a much more robust set of patterns for the exit trigger. Not yet recommended for the average user.
generic_mapper.xml
(107.08 KiB) Downloaded 722 times
Last edited by Jor'Mox on Thu Oct 18, 2018 3:59 pm, edited 41 times in total.

User avatar
SlySven
Posts: 927
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Generic Mapping Script

Post by SlySven » Fri Sep 02, 2016 3:23 am

You may get more precise results from the searchRoom(<roomId>) function as it has gained two extra (optional, omission is equivalent to false) booleans in the current code in the GitHub repositories for both the development and the delta preview source code to become searchRoom(<roomId>, [<case-sensitive> [, <exact-match>]]) - the plain command does a sub-string search and is not case sensitive but that can now be modified!

Area names in current code have mandatory names and mandatory uniqueness - they cannot have an empty name and the name must be unique amongst the currently defined areas. They are also case sensitive and case can be something that makes two otherwise identical names different - I spotted in the depths of that script something that squashed the case of the names (converted to lower-case for all area names) for a search (I think) that will fall over in the corner case where there are, for instance, "AnArea" and "anArea" as two different areas...

The current codebase does not clearly show the direction for which those exits where it shows a door marking (in the subset of normal exits on the XY-plain without a custom exit line) for 2 way exits - the coloured squared for the opposite directions are drawn on top of each other so if they are different it is unclear which direction is the one shown.

As it happens I am currently redesigning the code and it will be that doors can be indicated for any exit, even a stub or custom line and for the un-drawn (i.e. no custom line cases) of up, down, in or out markings on the room on the 2D map. This has come about as a side effect of refactoring the room internal structure, particularly the handling of exits {the code now allows for special stub exits - for when you just don't know what an unusual exit does yet, complete with markers on the 2D map showing that there are Special Exits WITHOUT a custom lines in that room and if there are none of those if there are any Special Exit stubs in that room!} and there will be a uniform set of lua exit feature commands based on a exit-pair {direction 1=north,2=north-east,...13=special; exit-string=nil for 1-12,name for 13} as part of a getAnyExitXXXX(...), getAllExitXXX(...) and setAnyExitXXXX(...) interface. The reason for using numbers is for I18n work so that scripts can work uniformly no matter what the normal exit directions are called in the current language - I have just put into the prototype code that allows the commands that the speedwalk code generates to be set for each normal exit direction on a global basis and for that to be over-ride-able on an exit by exit case - which opens the possibility of dropping in a script like a special exit can have - and special exits can have a name (identifier) that is not the command that is used (otherwise to identify a complex script you have to specify that script as the identifier) - but some care will need to be taking to make sure that it is at least backwards compatible for existing maps! :geek:

Jor'Mox
Posts: 1100
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox » Fri Sep 02, 2016 11:02 am

Yeah, I definitely did a bit of coding around the way Mudlet currently functions. So room searches are made exact by going back through and comparing the room names. Area names, so long as they are generated using the aliases provided, are forced to be unique independent of capitalization in a similar manner. I even built in doors functionality for up and down exits, specifically to allow me to check to see if visible exits match with known exits for a particular room, since a closed door can make a given exit invisible. However, I'm still using 2.1, and will be for the foreseeable future, so there are limits to what I can take advantage of. Once an official release for 3.0 comes out, then I can see about creating an updated version that uses its improved mapping functions.

By the way, the current code not only doesn't show where a door goes super clearly, if you have a door between areas, and the coordinates of the connected rooms don't line up correctly, it places the door on a spot midway between the two rooms, which can put it pretty much anywhere, including so far out of sight as to be unnoticed, or positioned as if it were a door for a different room entirely.

Anyway, it is my hope that this will let people with relatively simple mapping needs and limited coding ability put together a mapper for whatever game they play in. We shall see how successful that is.
Last edited by Jor'Mox on Sun Jan 15, 2017 11:09 pm, edited 1 time in total.

User avatar
SlySven
Posts: 927
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Generic Mapping Script

Post by SlySven » Fri Sep 02, 2016 9:38 pm

Jor'Mox wrote:...By the way, the current code not only doesn't show where a door goes super clearly, if you have a door between areas, and the coordinates of the connected rooms don't line up correctly, it places the door on a spot midway between the two rooms, which can put it pretty much anywhere, including so far out of sight as to be unnoticed, or positioned as if it were a door for a different room entirely...
Does the sample below look any better - there is rather a lot of different things on display here but I think you can determine the presence of doors on some of the exits!

When you say "if you have a door between areas" you mean between two rooms in the same "Area" but in two separated "clumps" I take it - so that the mid point where the current square is drawn is not clearly associated with either room? I'm not showing any area exits in the screen shot from my work in progress as I've still got to code for them:
Mudlet_wip2.png

Jor'Mox
Posts: 1100
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox » Sat Sep 03, 2016 1:08 am

No, I mean when the door is between two rooms in two different areas. This could potentially be avoided by including the room on the other side of the door into the area, but areas have specific in-game consequences in the MUD I play (and I wager a lot of MUDs), so I try to draw area borders as exactly as possible.

User avatar
SlySven
Posts: 927
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Generic Mapping Script

Post by SlySven » Sat Sep 03, 2016 8:27 pm

I think I get you, the coloured arrow (in the destination room's colours) does not have any indication of a door in the current code or rather it does but it is based on the "mid-point" of the coordinates for the two rooms but as different areas do not have a common coordinate system that is a bogus thing to do.

For what it is worth, I have addressed that in the "new" stuff I'm working on since I wrote the last post... 8-)
Mudlet_wip3.png
I must ensure that custom exit lines always get the same massive arrow-head if they are for an area exit as well!

Jor'Mox
Posts: 1100
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox » Sat Sep 03, 2016 9:15 pm

So, since you seem to be working on the map and related things, is there any chance that whatever it is that causes it to crash when you mess with it via the GUI too much has been fixed? Or is that one still lurking?

I ask because I have never seen it have any problems when I work with the map via code, but once I start clicking and dragging, I know it is just a matter of time before the whole thing crashes, which is a real pain.

User avatar
SlySven
Posts: 927
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Generic Mapping Script

Post by SlySven » Sat Sep 03, 2016 10:50 pm

Jor'Mox wrote:...but once I start clicking and dragging, I know it is just a matter of time before the whole thing crashes, which is a real pain.
Any particular symptoms or odd things happen just before it crashes? On what OS? "Clicking and dragging" what, a room, a group of rooms, a point on a custom exit line? Any error messages? Tell me more!

Jor'Mox
Posts: 1100
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox » Sat Sep 03, 2016 11:22 pm

So, I have experienced this on Mac OS X v.10.11, though I have also had it reported by someone using Windows of some variety (I don't know which one, but not Windows 10). I haven't noticed any specific symptoms that precede a crash, and I haven't noticed an exact pattern for what I'm doing when it happens. In a general sense, I and the other person who has reported it move single and multiple rooms, delete single and multiple rooms, and change exit assignments for individual rooms. If I remember correctly, the crash always seems to happen to me when I'm trying to bring up the menu, and the person who was using windows seemed to think it was related to having deleted multiple rooms somehow, but I haven't noticed such a connection, and specifically I have experienced a crash, restarted Mudlet, and manipulated the mapper without deleting any rooms, and experienced another crash, in one sitting.

When it was first reported to me, the person was using Mudlet 3.0.0 delta, so I recommended trying Mudlet 2.1 (because I had not yet had such a crash), but it obviously didn't fix it. Pretty much any time that I am using the GUI a significant amount, I can be certain that it will crash, but it can vary in how long it takes. Sometimes only 15 minutes is enough, and other times it can take an hour or more, though how much I'm using it is probably a factor there.

Oh, and I don't know if there are error messages, because it crashes Mudlet completely.

User avatar
SlySven
Posts: 927
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Generic Mapping Script

Post by SlySven » Sat Sep 03, 2016 11:35 pm

There WAS some nasty bugs in older 3.0 previews (inherited from 2.1 IIRC) in relation to deletion of rooms or movement of them between areas that could be causing the sort of things you describe - basically the areas' idea of rooms that they had was not being correctly maintained in the map data structures and these issues could be preserved in the saved form of the map. The current development and 3.0 preview source code (post-"delta") has additional stuff in place that should repair/fix/log (and report right in the main console if told to, check for that option on the "Map" tab of the "Options"/"Preferences" dialog) any such problems but I cannot remember whether the downloadable binaries have been recompiled to bring them up to that state...

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests