Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Redirecting a map into a mini window

Redirecting a map into a mini window

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Nate7240   (16 posts)  Bio
Date Sun 24 Jan 2010 06:31 PM (UTC)
Message
Alright this question has had me stumped for a good while now. And be aware that I am pretty much a noob to scripting. What I'm trying to do is take the map that is displayed when I walk into each room in aetolia, omit it from output, and redirect it into a mini window. Now so far, I have been able to capture the entire map using three triggers that use the EnableTrigger function. One trigger captures the line that starts the map and enables the next two trigger, the second is a wildcard that captures everything (the map), and the third marks the end of the map and disables itself as well as the second trigger. Now, this captures the map itself just like I wanted, but I am having problems drawing it into a miniwindow. I tried creating a miniwindow in the send box of the "middle" trigger that catches everything, and when I put %1 in the WindowText function to try and draw it all to the mini window, the last line of the map is all that shows up. I have not the slightest clue why the rest is not showing up. Maybe I am doing it all wrong, I don't know. Help would be greatly appreciated. Thanks.

Oh and ps, I use LUA, if you need to know.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Sun 24 Jan 2010 07:28 PM (UTC)
Message
You might want to look at my MapWindow plugin [1], which does exactly what you're talking about. It was made for Achaea, but you can probably learn from it no matter what MUD you're on.

You might have to right-click and View Source to view the plugin properly in the browser.

[1] http://jonathan.com/achaea/plugins/MapWindow.xml

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 24 Jan 2010 08:06 PM (UTC)

Amended on Tue 26 Nov 2013 03:46 AM (UTC) by Nick Gammon

Message
Also try watching my video showing an inventory being redirected to a miniwindow:

Template:post=9965 Please see the forum thread: http://gammon.com.au/forum/?id=9965.


Inventory, map, it is the same concept.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nate7240   (16 posts)  Bio
Date Reply #3 on Sun 24 Jan 2010 11:00 PM (UTC)
Message
I checked out both the tutorial and the plugin and still couldn't figure anything out. I suppose I'm just not experienced enough to understand it. Maybe there is another way to explain it. I tried modifying the inventory alias but to no success. I realize I'm a pain, but I need this pretty bad. Any other suggestions? Much appreciated.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #4 on Sun 24 Jan 2010 11:06 PM (UTC)

Amended on Sun 24 Jan 2010 11:07 PM (UTC) by Twisol

Message
Somehow I missed the fact that you were playing Aetolia. Both Aetolia and Achaea have very similar (if not identical?) map formats, so my plugin should work pretty much entirely. You might have to fix it a bit so it doesn't wait for a prompt, depending on where the MAP appears... and of course, it wouldn't have to send MAP on its own in most cases, since it appears as you walk.

It won't automatically update unless you have my ATCP plugin as well, and I never got it working outside Achaea, so you'd have to fall back on some other method of telling when you're moving.


As for why only the last line shows up, maybe you're drawing all lines onto the same area. You want to draw every line below the previous one, based on your font's height. I can't tell for sure without seeing your code; feel free to paste it here (surrounded by [code] tags).

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nate7240   (16 posts)  Bio
Date Reply #5 on Sun 24 Jan 2010 11:19 PM (UTC)
Message
Alright all I have so far is this, and it is only for the specific room I am in for the time being. I can have it omit the map from the "catch all" trigger so I know it is catching everything. Problem is I don't know how to get it into a miniwindow (not experienced enough is what it boils down to).


Start trigger:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   lines_to_match="10"
   keep_evaluating="y"
   match="^\-\-\-\-\-\-\-\-\-\- v13042 \-\-\-\-\-\-\-\-\-\-\-$"
   name="start"
   omit_from_log="y"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>EnableTrigger("middle", true)
EnableTrigger("end", true)

</send>
  </trigger>
</triggers>


Middle trigger (catches the map):


<triggers>
  <trigger
   expand_variables="y"
   keep_evaluating="y"
   match="^(.*?)$"
   name="middle"
   omit_from_log="y"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  </trigger>
</triggers>


end trigger:


<triggers>
  <trigger
   expand_variables="y"
   lines_to_match="10"
   keep_evaluating="y"
   match="^\-\-\-\-\-\-\-\-\-\- 5\:\-13\:3 \-\-\-\-\-\-\-\-\-\-$"
   name="end"
   omit_from_log="y"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>EnableTrigger("end", false)
EnableTrigger("middle", false)
</send>
  </trigger>
</triggers>



Hopefully this helps.


Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #6 on Sun 24 Jan 2010 11:50 PM (UTC)
Message
It looks like you have the right idea in regards to collecting the data. Did you have any other code? I know you mentioned using WindowText(), do you still have that code somewhere?

The way I did my plugin, I took each line and put it in a table. The corresponding function in my plugin is ParseLine, at the end of the script. Only after I matched the end trigger did I actually draw all the lines. That way I'm able to more easily draw each line in its own row. The corresponding function here is the DrawGrid function in the Window table, and the other two functions it calls indirectly, DrawRow and DrawCell. The Window table was my way of encapsulating the miniwindow, so you'll find most of the operations directly affecting the miniwindow in there.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nate7240   (16 posts)  Bio
Date Reply #7 on Mon 25 Jan 2010 12:12 AM (UTC)
Message
Yeah, I removed it before but this is what the catch all trigger looked like:



<triggers>
  <trigger
   expand_variables="y"
   keep_evaluating="y"
   match="^(.*?)$"
   name="middle"
   omit_from_log="y"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>win = GetPluginID ()
font = "f"

WindowCreate (win, 0, 0, 300, 300, 4, 2, ColourNameToRGB("white"))
WindowText (win, "f", "%1", 5, 10, 0, 0, ColourNameToRGB ("blue"), false)
WindowShow (win, true)
</send>
  </trigger>
</triggers>

Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #8 on Mon 25 Jan 2010 12:20 AM (UTC)
Message
Nate7240 said:
win = GetPluginID ()
font = "f"

WindowCreate (win, 0, 0, 300, 300, 4, 2, ColourNameToRGB("white"))
WindowText (win, "f", "%1", 5, 10, 0, 0, ColourNameToRGB ("blue"), false)
WindowShow (win, true)
</send>
  </trigger>
</triggers>


Right, this is your problem. You're recreating the window every time you get a line. No wonder only the last line is showing. ;)

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nate7240   (16 posts)  Bio
Date Reply #9 on Mon 25 Jan 2010 12:21 AM (UTC)
Message
AHA! How could I be so dumb, oh yeah thats right, like this: How would I go about fixing this? :)
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #10 on Mon 25 Jan 2010 12:43 AM (UTC)
Message
Nate7240 said:

AHA! How could I be so dumb, oh yeah thats right, like this: How would I go about fixing this? :)


This should be a good start. :)

Twisol said:

The way I did my plugin, I took each line and put it in a table. The corresponding function in my plugin is ParseLine, at the end of the script. Only after I matched the end trigger did I actually draw all the lines. That way I'm able to more easily draw each line in its own row. The corresponding function here is the DrawGrid function in the Window table, and the other two functions it calls indirectly, DrawRow and DrawCell. The Window table was my way of encapsulating the miniwindow, so you'll find most of the operations directly affecting the miniwindow in there.


Take a look over my plugin again and see if you can understand it. Most of the scripting is in the script section at the bottom, and the triggers have a script="foo" attribute that executes a function when it's matched.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nate7240   (16 posts)  Bio
Date Reply #11 on Mon 25 Jan 2010 12:52 AM (UTC)

Amended on Mon 25 Jan 2010 12:54 AM (UTC) by Nate7240

Message
I hate to say it, but I looked at it, and I have not the slightest clue where to begin...(I'm a "casual scripter",and thats being generous)

I understand the problem, Just can't fix it, heh.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #12 on Mon 25 Jan 2010 12:59 AM (UTC)
Message
Alright. The triggers themselves should be easy enough to understand. They manage the state of the plugin, only letting things happen when other things have happened beforehand. You should be able to see your three-trigger-sandwich in there for the MAP output, too.

The functions, well, there are only the ones I pointed out that you need to pay attention to. The rest manage the alias-based settings, like window location and font size. If you're having problems within specific functions, I can help you through those, but there's not much more I can tell you at this point.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nate7240   (16 posts)  Bio
Date Reply #13 on Mon 25 Jan 2010 01:04 AM (UTC)
Message
alright I'm going to look over it for bit, I'll get back to you with the results alright?
Top

Posted by Nate7240   (16 posts)  Bio
Date Reply #14 on Mon 25 Jan 2010 10:14 PM (UTC)
Message
After I looked over this, I figured I'd Give it a try. Now, after toiling with it all day I've managed to come up with this, which is in my "catch all" trigger. Now when I go to see if it works, a little box shows up in the top left hand side of my screen, which I wanted to. Problem is, there is no map to go with it. I don't get any errors at the moment, but I think there is nothing in the table to display. You can see where I tried inserting everything the "catch all" trigger caught, but to no success. Help would be greatly appreciated. Here is the trigger:


<triggers>
  <trigger
   expand_variables="y"
   keep_evaluating="y"
   match="^(.*?)$"
   name="middle"
   omit_from_log="y"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>

local win = GetPluginID () .. ":map"
local font = "f"

WindowCreate (win, 0, 0, 0, 0, 4, 0, 0)
WindowFont (win, font, "Lucida Console", 9)  





local map = {}
local line, wildcards, styles = "%1"
  table.insert (map, styles)
local max_width = WindowTextWidth (win, font, "Map")


max_width = math.max (max_width, WindowTextWidth (win, font, line))

local font_height = WindowFontInfo (win, font, 1)

local window_width = max_width + 10

local window_height = font_height * (#map + 2) + 10

WindowCreate (win, 0, 0, window_width, window_height, 4, 0, ColourNameToRGB "#373737")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

WindowText (win, font, "Map", 5, 5, 0, 0, ColourNameToRGB  "yellow")



local y = font_height * 2 + 5

for i, styles in ipairs (map) do

   local x = 5
   for _, style in ipairs (styles) do
   x = x + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
   end -- for
   y = y + font_height

end -- for each map item

WindowShow (win, true)




</send>
  </trigger>
</triggers>
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.


58,801 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

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