[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Redirecting a map into a mini window

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Redirecting a map into a mini window
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1  2 

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 26 Jan 2010 05:14 AM (UTC)  quote  ]
Message
You seemed to have combined the various parts of the earlier suggestions into one trigger. But it won't work like that. For every line you receive, you are making a new window, discarding all the earlier lines.

You have to start collecting the map at the start, keep adding to the table in the "catch all" trigger, and display the results at the end of the map.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nate7240   (16 posts)  [Biography] bio
Date Mon 25 Jan 2010 10:14 PM (UTC)  quote  ]
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>
[Go to top] top

Posted by Nate7240   (16 posts)  [Biography] bio
Date Mon 25 Jan 2010 01:04 AM (UTC)  quote  ]
Message
alright I'm going to look over it for bit, I'll get back to you with the results alright?
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Mon 25 Jan 2010 12:59 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nate7240   (16 posts)  [Biography] bio
Date Mon 25 Jan 2010 12:52 AM (UTC)  quote  ]

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.
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Mon 25 Jan 2010 12:43 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nate7240   (16 posts)  [Biography] bio
Date Mon 25 Jan 2010 12:21 AM (UTC)  quote  ]
Message
AHA! How could I be so dumb, oh yeah thats right, like this: How would I go about fixing this? :)
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Mon 25 Jan 2010 12:20 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nate7240   (16 posts)  [Biography] bio
Date Mon 25 Jan 2010 12:12 AM (UTC)  quote  ]
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>

[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sun 24 Jan 2010 11:50 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Nate7240   (16 posts)  [Biography] bio
Date Sun 24 Jan 2010 11:19 PM (UTC)  quote  ]
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.


[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sun 24 Jan 2010 11:06 PM (UTC)  quote  ]

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
[Go to top] top

Posted by Nate7240   (16 posts)  [Biography] bio
Date Sun 24 Jan 2010 11:00 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 24 Jan 2010 08:06 PM (UTC)  quote  ]
Message
Also try watching my YouTube 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
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sun 24 Jan 2010 07:28 PM (UTC)  quote  ]
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
[Go to top] 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.


3,112 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]