Page 12 of 45

Re: Generic Mapping Script

Posted: Thu Jul 20, 2017 12:07 pm
by Jor'Mox
Okay, so the onPrompt event just needs to detect that a prompt happened reliably, so capturing any actual info, or getting both lines of the prompt isn't important. Given your example prompt, you could use a regex like this to just capture the second line. ^\d+\(\d+\)hits \d+\(\d+\)forcep \d+\(\d+\)move>

As for the exits, a regex like this should work okay. ^Obvious Exits: ([\w\[\]\s]+)
But then you would need to remove any instance of "[closed]" (or any other possibilities that don't constitute directions) from the string before storing it in map.prompt.exits. Something like this would strip out anything enclosed in parentheses: map.prompt.exits = string.gsub(matches[2],"(%[%a+%])","")

As for the room name issue, assuming that the room name is always the first instance of text of the specified color (as it sounds like you are using a color trigger to capture room names), I think using a simple check variable would be the easiest way to deal with it. There would be two parts, the first in the color trigger that is trying to capture the room name, and the second would be in the prompt trigger, where you would reset the variable.

In the color trigger:
Code: [show] | [select all] lua
if not room_found then
   map.prompt.room = matches[1]
   room_found = true
end
And then in the prompt trigger: room_found = false

Just make sure that the prompt trigger is located BELOW the color trigger, so that it executes after the color trigger goes over the line with the prompt, and you should be good to go.

Re: Generic Mapping Script

Posted: Thu Jul 20, 2017 6:22 pm
by Rann
Thank you, it did post. It's the one that starts with "Thank you for responding..."

Re: Generic Mapping Script

Posted: Thu Jul 20, 2017 6:37 pm
by Rann
Thank you for writing these out, Jor. I will implement these. Thank you.

Re: Generic Mapping Script

Posted: Sat Jul 22, 2017 9:56 pm
by Daagar
Neglected playing with this for a long time, as I usually wrote my own (usually going for something more complex than needed). However, this is absolutely wonderful. Took just minutes to craft a couple of appropriate triggers and get basic functionality going. I never made mine abstract enough to reuse easily, which becomes annoying quickly when you hop around muds like I tend to do. This is just plug and play!

Re: Generic Mapping Script

Posted: Sun Jul 23, 2017 2:14 pm
by Jor'Mox
I'm really glad you found this easy to use, and useful. That was the whole idea behind doing it. There was never really any solid foundation that someone could make a mapper from, you had to start from scratch, which is a LOT of work if you don't have the game feeding you the critical information, and a real pain to figure out. Once I had it working solidly, I figured I might as well share with everyone else.

Re: Generic Mapping Script

Posted: Sun Jul 30, 2017 5:51 pm
by Vadi
Small improvement. I don't know if config is idempotent or not though:
Code: [show] | [select all] lua
    elseif event == "sysConnectionEvent" or event =="sysInstall" then
        config()
    end

Re: Generic Mapping Script

Posted: Sat Aug 12, 2017 11:38 pm
by Votrepatron
I have found this very helpful!

I am throwing an error. I wanted some help.

17:22:31.646 [ERROR:] object:<80> function:<Alias80>
17:22:31.646 <[string "Script: Map Script"]:741: No room detected!>

It started after I tried to clear the current map that was showing up by clicking delete on it. (which was not a good idea now that I look back on it.)
I can no longer map.

Re: Generic Mapping Script

Posted: Sun Aug 13, 2017 12:32 pm
by Jor'Mox
Right, so that is a rather understandable problem, actually. In theory, you should be able to restart Mudlet, and then get back to mapping.

Re: Generic Mapping Script

Posted: Sun Aug 13, 2017 5:08 pm
by Votrepatron
I tried that. I keep trying to re-install it and set it up again, but even if I delete the saved profiles it just recreates them when I install again.

Any ideas how to do a full wipe of all data and start clean?

Re: Generic Mapping Script

Posted: Sun Aug 13, 2017 5:26 pm
by Jor'Mox
So, looking at the code, and the error you are reporting, it is obvious that of the 4 things necessary for basic mapping to work, at least two are happening, and those are the onNewRoom and onPrompt events getting raised. But, based on the code, something is causing the internal variables that handle the room name and/or exits to not be updated, suggesting that whatever you have that is trying to capture those values and store them in the map.prompt.room and map.prompt.exits variables isn't working properly.

To help figure out what is going on, I recommend going into your prompt trigger, and before you raise the onPrompt event, display(map.prompt), that way you can look at the values that it is working with, to see if there are any obvious issues. If there aren't any obvious problems, or you can't fix whatever problems you see, then I'll need as much info as you have about the triggers to capture the room name and exits, whatever values are getting stored there, etc.