Generic Mapping Script

All and any discussion and development of the Mudlet Mapper.
wtp
Posts: 5
Joined: Tue May 23, 2017 10:44 pm

Re: Generic Mapping Script

Post by wtp »

I give up. I didn't realize I need to be a full blown developer to use this thing, and sorry for bugging you. No wonder nobody plays MUDS anymore good lord.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Generic Mapping Script

Post by Vadi »

Sorry about your experience. There are MUDs that have mapping working out of the box, see for example ones listed in http://wiki.mudlet.org/w/IRE_mapping_script.

Unfortunately not all of them cooperate in making mapping easy so we can't have a one size fits all for this!

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

Re: Generic Mapping Script

Post by Jor'Mox »

Vadi wrote:Unfortunately not all of them cooperate in making mapping easy so we can't have a one size fits all for this!
Ultimately, this is what it comes down to. My script handles the behind the scenes work, but there is no way to guess the right way to get the actual information about rooms for even a large percentage of MUDs out there, so while I could make some dummy triggers for things, they would still need to be changed around to fit with what you see. This is especially true for a prompt trigger, since even within a given game, you can usually change your prompt around to show what you want. Most people who are generally comfortable with making their own triggers and such in Mudlet have the necessary skill level to make this work, at least in a general sense (though they may need some help for occasional exception-type cases). And for those who can't make regex triggers on their own, you can often find someone who can come up with the patterns for you here on the forums if you can post a few examples of what you are seeing in the game. Either way though, you still have to read through the comments at the top to see what needs to be done, and what you are getting yourself into. Mapping for MUDs is NOT a trivial task.

GErswin
Posts: 17
Joined: Fri Jun 09, 2017 6:12 am

Re: Generic Mapping Script

Post by GErswin »

I am 100% new to all this, and feeling pretty lost. Every instruction I find seems to assume I know the basics, but I can't find the basics anywhere.

I've got the lua script installed as a "script", but how do I access any of the commands? I see on this forum and in the instructions at the top of the script that I need to use aliases like "start mapping" but how do I use that? Typing it into the command console doesn't work.

Thanks in advance for any help.

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

Re: Generic Mapping Script

Post by Jor'Mox »

The aliases referenced are all used by typing them into the command line. When you FIRST start working with a map, you need to provide the name of the area that you are in when you use the "start mapping" command, like this: start mapping Main Town
After that, whenever you want to begin mapping again, just stand somewhere that is already mapped, and type "start mapping" on its own.

Before any of that happens though, you need to find a way to collect the four critical pieces of information that cannot be generalized, namely you need a way to capture the room name, the room exits, the fact that a room has been seen at all, and the fact that a prompt has been displayed. Depending on the game, it is at times possible to capture the room name and exits from the prompt itself, leaving you to only need two triggers, one for the prompt, and one that tells you when a room is displayed (I usually am able to do this by creating a trigger for the line in a room description that says where the exits are, as it seems to be fairly distinct).

If you aren't comfortable making the triggers yourself, if you post sufficient examples of what is needing to be captured, someone here can probably help you. Sometimes the necessary triggers can be rather complex, so don't be discouraged if you need someone else to help out, or if it takes multiple attempts to get things working properly (even with someone else helping).

Once the triggers are setup, then I can walk you through using the relevant aliases, as needed.

GErswin
Posts: 17
Joined: Fri Jun 09, 2017 6:12 am

Re: Generic Mapping Script

Post by GErswin »

Thanks for the help! I really appreciate it.

I've figured out how to set up triggers for the exits and the room name. Those were easy because I could do color triggers.

The room description is more difficult because it's multiple lines. Is there a way to capture everything after a certain line (e.g. the room title) and then capture until a line break? I don't think any room has a line break in its description until the description is completed.

My MUD looks like this:
47H 80V 1499X 0.00% 0C Exits:N>
The Reception
This is the reception of the lodge, where you would sign in for a
room. This is also a very popular place where adventurers sit around and
share tales of their journeys. Some stairs in the back lead up to the
quarters.
Now I am not sure what to do with this trigger information. How do I pass it to the main mapping script?

Besides that, typing "start mapping NewArea" returns my mud's default bad input response, which means Mudlet isn't intercepting the line. The script is definitely activated though, because I can type "lua map.help" and it gives me the stuff from the top of the mapping script. What am I missing?

GErswin
Posts: 17
Joined: Fri Jun 09, 2017 6:12 am

Re: Generic Mapping Script

Post by GErswin »

Been working at this for several hours, and I've made some progress. I understand the basics a lot more now.

Here are some general learnings for anyone else stumbling on this thread X years from now:
  • - You can't call Lua functions from the main console. They have to be called in a trigger, or keybinding, or alias, or something like that. For example, I created a keybinding (ctrl-W) called DoSomething, and it calls whatever function I'm wanting to test at the time.

    - Any Lua function in any script is fair game. If it exists, it can be called from any alias, trigger, etc.

    - Lua fails silently. This is really frustrating. For example, setAreaName(001, MyArea) seems to do nothing. No error or indication that it even tried to run. However, setAreaName(001, "MyArea") with the quotation marks works perfectly because that's the syntax the function needs. If you're wondering if your scripts is even firing, copy-paste all your code to a notepad file, then delete it all from Mudlet and replace it with echo("I'm working!"). I've used this countless times to discover that my keybinding or whatever wasn't even firing. Or if I see the echo, then I'll know my code is silently failing.

    - Variables get deleted at startup for some reason. Checkmarking them is supposed to save them, but it doesn't work. I created a basic script that declares them on startup each time. Weird, but fine.
I would still like some help figuring out how to capture the lines I need from my post above, if someone has time.

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

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, so, you don't need to capture the room description. This script doesn't use them because some games have rooms with variable descriptions.

Second, regarding the room name and exits, you need to store them in map.prompt.room and map.prompt.exits respectively. The room name can be whatever you like, so long as it is consistent. The exits need to be a string containing the full exit directions separated by spaces and/or commas, potentially including an "and" at the end of the list, like this: "east, west, north, and south"

Third, you need to raise two events to let the mapper know what to do. The first event tells the mapper that you have just seen a room, and you raise it like this: raiseEvent("onNewRoom")
The second event tells the mapper that a prompt occurred, and you raise it like this: raiseEvent("onPrompt")
Note that there are other events, detailed in the help, that are also important for making the mapper more robust, but they are not critical for getting it to work on a basic level.

Regarding your alias issue, as well as your comments about Lua failing silently, what you need to do is open up the script, and then click the button that looks like a red circle with a white exclamation point in the middle. This will open up a small, black window in the bottom of the script area, in which Lua displays errors. In all likelihood, the alias you need isn't working because it hasn't been created, because the config() function failed due to the Simple Window Manager script not being installed, as indicated in the initial post.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Generic Mapping Script

Post by Vadi »

GErswin wrote:Been working at this for several hours, and I've made some progress. I understand the basics a lot more now.

Here are some general learnings for anyone else stumbling on this thread X years from now:
  • - You can't call Lua functions from the main console. They have to be called in a trigger, or keybinding, or alias, or something like that. For example, I created a keybinding (ctrl-W) called DoSomething, and it calls whatever function I'm wanting to test at the time.

    - Any Lua function in any script is fair game. If it exists, it can be called from any alias, trigger, etc.

    - Lua fails silently. This is really frustrating. For example, setAreaName(001, MyArea) seems to do nothing. No error or indication that it even tried to run. However, setAreaName(001, "MyArea") with the quotation marks works perfectly because that's the syntax the function needs. If you're wondering if your scripts is even firing, copy-paste all your code to a notepad file, then delete it all from Mudlet and replace it with echo("I'm working!"). I've used this countless times to discover that my keybinding or whatever wasn't even firing. Or if I see the echo, then I'll know my code is silently failing.

    - Variables get deleted at startup for some reason. Checkmarking them is supposed to save them, but it doesn't work. I created a basic script that declares them on startup each time. Weird, but fine.
I would still like some help figuring out how to capture the lines I need from my post above, if someone has time.
For sure.

1) use "lua <code>", ie lua print("hello")

2) Mudlet doesn't spam you out with errors in the main window, but there's an option for it if you'd like. See http://wiki.mudlet.org/w/Manual:Introdu ... _your_code on where the errors go!

3) that's correct, variables get reset, see http://wiki.mudlet.org/w/Manual:Using_V ... _variables on how to save them!

GErswin
Posts: 17
Joined: Fri Jun 09, 2017 6:12 am

Re: Generic Mapping Script

Post by GErswin »

Thanks for the help! It's greatly appreciated.

At this point I'm writing my own mapping script from scratch so I can understand what's happening, rather than relying on the script in this thread which is too complex for me to troubleshoot given my current knowledge.

I've got it so I can add an area, and a room with a name and description - but only if I manually give it the name and description. I am still not sure how to capture my room's name and description through triggers. I can get the exits since they always come after a set of text ("Exits:").

- I can use a color trigger to highlight the room name, but I don't know how to save that as a variable.
- I figure my best bet is to capture the first few lines after sending specific commands (like "move north" or "look"), but I don't know how to do that. I've spent about an hour fooling around with getLines but it either returns something really weird, like "[ OK ] - Lua module rex_pcre loaded" (no idea what that's about) or something like "Table: 08DB9345", which I assume is because getLines returns a table.

Any ideas? How can I best capture the title and description when the output is like this?
35H 59V 1499X 0.00% 0C Exits:N> look
The Reception
This is the reception of the lodge, where you would sign in for a
room. This is also a very popular place where adventurers sit around and
share tales of their journeys. Some stairs in the back lead up to the
quarters.
A pile of worn maps sits in the corner, free to adventurers.
A wooden bulletin board with the heading 'Wanted' is posted on the wall.
And the reason I want the description is because in CMUD I used to search the descriptions for specific things I remembered about a room.

Post Reply