miniwindow plugin with alias/trigger help

Posted by Tsheller on Mon 18 May 2009 09:12 AM — 6 posts, 28,246 views.

USA #0
So I am looking to write a plug-in that I need a little help on.. I can understand the basic elements needed to accomplish what I need, but whenever I try to put them all together, it doesn't ever come out right.

I want to take the output of a command and put it into a miniwindow that is 20 lines long. A couple issues...

the output of the command 'map' isn't easily matchable. What I thought would be possible is have an alias (map) that sends the command map and turns on a trigger to capture everything until it matches the '>' character at the very end (which is the prompt) This would turn off the match everything trigger.



Netherlands #1
Sounds like a good plan. Can you show us what you have managed to figure out so far? :)
Australia Forum Administrator #2
Your basic idea is sound. Some MUDs like Aardwolf help you by putting <MAPSTART> and <MAPEND> around their maps. Failing this, you probably need a trigger that matches as close as you can get to a map line.

For example, if the map starts with something like this it would help:


+-----------+ 


Failing something that specific, maybe map lines only have certain characters like compass directions, hyphens and so on?

So what you could do is, after you type "map" it enables a trigger that tries to match the very first map line. This trigger then enables another trigger that matches anything. Finally you need a way of knowing when the map ends, which might be a line that *doesn't* have things like hyphens and compass directions.

USA #3
Hey thanks for the replies.

I know how to turn on and off triggers/alias/timers when other timers or triggers are 'triggered' or go off.. but how the actual script would be put together in a plugin.. As far as creating the window and getting that data to a miniwindow.. I get lost.

Nick -

Unfortunately for the map it first sends a blank line, then the characters could be an X or a + for the first line of the map, however, the only map characters are 0-9 numbers that can be up to six digits (102142) for example. The other characters would be, (,), -, |, <, >, ', %, or an actual ,.

Then there is a blank line

Then there is a legend describing what various characters and colors mean. This I don't really need to capture, if it could be triggered it could just be omitted from output.


<#****** / ||||||> 
                                X   43026  X   42007 'X   43050              
          +          +          X----------X          X          XXXXXXXXXXXX
                                X   42306  X   42004      42022  |   42023  |
          +          +XXXXXXXXXXX          X          X          XXXXXXXXXXXX
                     X   42059  |   42058 %X   42195      42387  X           
          +          XXXXXXXXXXXX----------X          XXXXXXXXXXXXXXXXXXXXXXX
                                X < 42002>'|   42001  |   42003      43090  |
          +XXXXXXXXXXXXXXXXXXXXXX----------X          XXXXXXXXXXXXXXXXXXXXXXX
          X   42010      42025      42008      42005  |   42015  X           
          XXXXXXXXXXXX----------X          X          X----------X          +
                     X   43027      42197      42196      42303  X           
          +          XXXXXXXXXXXX          X          XXXXXXXXXXXX          +
                                X   42198      42036  X                      
          +          +          X          X          X          +          +

  ' Up       , Down     % Up/Down
  Inside     City       Road       Trail      Field      Woods      Forest     
  Hills      Mountains  Swamp      Dock       Cave       Pasture    Heath      
  Pit        Leanto     Lake       River      Ocean      Reef       Underwater 
  
<#****** / ||||||> 


(note: There is no blank first line in this one before the top of the map, but depending on the position of my avatar in the map, the first line can be entirely blank)

Unfortunately, I got so frustrated at the plugin I attempted I just deleted it thinking a fresh start was in order..


Amended on Wed 20 May 2009 09:54 PM by Tsheller
Australia Forum Administrator #4
You have the problem well-described. I would like to see you try it and post the resulting plugin. Then we have something concrete to work with.

The basic plugin would be like the Aardwolf miniwindow mapper plugin:

http://www.gammon.com.au/forum/?id=8816

You just need to change how it detects the start and end of the map.

As you suggested before, once you type "map" you could enable the trigger that detects the first line. This could be a simple regular expression like this:


"^[X+',%\-<>()0-9 ]{10,}$"


That matches a line with the characters you mentioned, plus the numbers 0-9, or a space. However it only matches if the line consists entirely of at least then of those characters (to avoid false matches on really short lines).

You could change the 10 to something somewhat larger if the map is usually as large as you have shown.

Once that matches you can start capturing lines.

The legend could be handy as a way of detecting when the map ends, that is match on " ' Up , Down % Up/Down".
USA #5
<triggers>

<trigger
enabled="y"
match="^[X+',%\-<>()0-9 ]{10,}"
script="map_redirect"
omit_from_output="y"
name="map_start"
sequence="100"
>
</trigger>

<trigger
enabled="n"
match="*"
script="map_redirect"
name="multi_line_map"
omit_from_output="y"
sequence="10"
>
</trigger>

<trigger
enabled="y"
match="^ \' Up \, Down \% Up\/Down$"
script="map_redirect"
omit_from_output="y"
name="map_end"
sequence="5"
>
</trigger>


</triggers>

So that's what I have to trigger.. which seems to work to catch the first lines. I got the map_end trigger to capture the end of the map like you suggested and that works just fine.

Can I add:

<send>
EnableTrigger (multi_line_map, true)
</send>

to the map_start trigger? And then make it false on the map_end?

Taking a look at the plug-in link you gave me, I really don't understand the script part. A lot of it seems unnecessary (like the linking) and it really just confuses me. I honestly haven't figured out the basic concept of taking the captured information and moving it to the miniwindow.