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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Mini-window for public chatter
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Mini-window for public chatter

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


Pages: 1  2  3  4  5  6 7  8  9  

Posted by Boris_Bee   (5 posts)  [Biography] bio
Date Reply #75 on Sat 13 Oct 2012 09:15 PM (UTC)
Message
I'm new to mush and am in the process of trying to convert all my zmud scripts over to mush as I'v just about had it with how unstable zmud.

I am using Nick's modified version of the scrolling chat window and I have it working fine, but there is one thing I would like to be able to do and have yet to figure it out. I'm trying to make an alias that will send whatever I want to the window as if it were captured from the mud. I'v tried to decipher the script as best I could and as far as I can tell it needs to trigger off a style and so I can't just send it a text string to have it display in the window. Is there anyone that can help me do this?

Thanks!
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #76 on Tue 16 Oct 2012 03:02 AM (UTC)

Amended on Wed 17 Oct 2012 10:12 AM (UTC) by Fiendish

Message
I would add the following function:


-- Takes input as a string with embedded color codes. Use via CallPlugin().
-- See:   http://mushclient.com/scripts/doc.php?function=CallPlugin
-- You can manually embed your own colors using @ codes described in mw.lua to push any colorized line you want to the log window.
-- Example: CallPlugin("565dae21eb816a2fdb8d50f9","storeFromOutside","HELLO@RHello@Mhello")

require "mw"
function storeFromOutside(text)
   chats (nil, nil, nil, mw.ColoursToStyles(text))
end


And then you can make any alias you want, or any other script you want, send lines to the plugin as if they were captured from the game using the CallPlugin interface

[EDIT] fixed invocation of ColoursToStyles per notice below

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Boris_Bee   (5 posts)  [Biography] bio
Date Reply #77 on Tue 16 Oct 2012 07:24 AM (UTC)
Message
Thanks Fiendish, I managed to get it working with that.

There is a problem minor issue though. When I require "mw" my scripts still have issue with finding the functions required in mw.lua. The only way I was able to solve this issue was by copying the mw functions I needed into the chat script file. Is there a way I can fix this so I'm not having to needlessly add code?

Thanks
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #78 on Tue 16 Oct 2012 01:33 PM (UTC)
Message
Hmm. Is your mw.lua in the Lua directory? And what version of MUSHclient are you using?

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Boris_Bee   (5 posts)  [Biography] bio
Date Reply #79 on Wed 17 Oct 2012 08:22 AM (UTC)
Message
4.73, and yea it is. Seems the movewindow.lua is found correctly since the script uses that, but mw is a no go.
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #80 on Wed 17 Oct 2012 10:10 AM (UTC)

Amended on Wed 17 Oct 2012 10:12 AM (UTC) by Fiendish

Message
Ahh, oops. Try prefixing the function calls with "mw."

This is because of the line
module (..., package.seeall)
in the file. (http://lua-users.org/wiki/ModulesTutorial)

I have edited my earlier post to reflect this.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Tiredchris   (17 posts)  [Biography] bio
Date Reply #81 on Fri 14 Dec 2012 10:31 PM (UTC)
Message
I learned how to swap stuff out with nicks inventory window, and have made few plugins to have stats in windows, and all of them are movable.

What I'm at now is trying to figure out the resizing aspect/scrolling that you have in this plugin.

Could someone please detail how this script does that, thuroughly. I cant tell what is what, since in comparison I was told most of how the inventory window worked in Nicks video.
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #82 on Sat 15 Dec 2012 05:26 AM (UTC)

Amended on Sat 15 Dec 2012 02:56 PM (UTC) by Fiendish

Message
Quote:
What I'm at now is trying to figure out the resizing aspect/scrolling that you have in this plugin. Could someone please detail how this script does that, thuroughly.

Math. Also programming. :\

*sigh* Ok, here goes...

As with just about any aspect of user interaction, the place to start looking is in functions that define what happens when the user activates the mouse button while over a hotspot. These are associated with the various hotspots in the calls to WindowAddHotspot and WindowDragHandler (see MUSHclient miniwindow docs). By inspection of the plugin code we can see that they are named MouseDown, ResizeMoveCallback, and to lesser degrees MouseUp, CancelMouseDown, and ResizeReleaseCallback.

Quote:
scrolling


Scrolling the text requires that you think of the chat window as an actual narrow window onto a much larger body of text with sequentially numbered lines. At any moment, the window view displays a set of lines of text starting from some line number (let's call it TOP_LINE) and ending at TOP_LINE+N, where N is the number of lines that fit in the window given its current size. When you scroll up and down, all you are doing is changing the value of TOP_LINE. Either subtracting from it when scrolling up, or adding to it when scrolling down. Obviously special care must be taken to not scroll off the ends (you can't show line number -1, for example).

Once you have basic scrolling, the next part is constructing a proportionally sized and spaced scrollbar widget.

The principles of a proportional scrollbar are as follows:

Starting with a chat storage buffer such that each array index contains a single printable line of text (this means chats in the buffer must already be line-wrapped for display. See function fillBuffer that breaks up styleruns according to the miniwindow width), you need to first find out how large to make the shuttle and then where to position it on the scrollbar...

You have a number of buffered text lines (Let's call this number of lines T). You also have a window that can display some number of lines at a time (let's call this number of lines D and is the text display area height divided by the text line height). The third number we'll need is the number of vertical pixels that you want the scrollbar region to fill (let's call that number of pixels P). This could be the entire vertical height of the miniwindow or some subset thereof (accounting for titlebar, resize widget, etc). The ratio of lines that can be displayed to total lines (D/T) governs both the size of the scrollbar shuttle and which set of lines gets displayed for a given bar location.

The height of the scroll shuttle is always going to be math.max(MIN_SHUTTLE_HEIGHT, math.min(P, (D/T)*P)). This means use a proportional number of the available pixels except for two cases. You want a minimum scroll shuttle height so that the shuttle doesn't get too small to grab with the cursor if you have thousands of buffered lines and a very small window. You also want to make sure the shuttle doesn't try to be larger than the designated scrollbar area if you have fewer buffered lines than will fit in the miniwindow (D/T would then be > 1).

The position of shuttle in the scrollbar should be determined in the following way. Divide the scrollbar into a proportional series of pixel increments, one step for each possible line of text to be shown, by (P/T). Now whatever line of text you want to start (or end, depending on orientation preference) the display section with can be directly related to a shuttle position and vice versa.

Quote:
the resizing


I'm actually going to explain how it *should have* been done, because in hindsight I have always made resizing functions a bit longer than they need to be. Also the implementation posted in this thread is buggy. Discovering how is left as an exercise for the reader after reading the next paragraph.

On MouseDown save the x and y distances from the mouse's position to the bottom right corner of the miniwindow (width-WindowInfo(win, 17) and height-WindowInfo(win, 18)). Call them offset_x and offset_y. Then, every ResizeMoveCallback, set the window width and height to the current mouse position relative to the miniwindow (WindowInfo(win, 17) and WindowInfo(win,18) again) plus the original offsets, bounded by some arbitrary minimum width/height and some maximum width/height equal to reaching the edges of the screen.

The method implemented at the beginning of this thread is quite similar in nature. But I think that storing and using the original corner offset is probably a philosophically better idea than tracking the mouse movement at every drag step, but they can be equally functional if both done correctly.

After the window has been resized, we want to re-wrap all the old chats so that it all fits nicely into the new width. For performance reasons we can only safely do this when the user releases the mouse button after dragging (ResizeReleaseCallback), because the mechanism for linewrapping the stored chats is, sadly, not nearly fast enough to run dozens of times per second while dragging the resizer.

[EDIT] made a few edits for organizational clarity

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by CincyMush   (15 posts)  [Biography] bio
Date Reply #83 on Fri 28 Dec 2012 08:52 AM (UTC)
Message
I am curious if some one has adapted this to support multiple windows. I have some many channels to keep an eye on I'd like to pop more than one window and direct the output accordingly, but I don't see an easy way to have twoinstances of this or to pop a second mini-window with a distinct ID that can be re-directed to.
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #84 on Fri 28 Dec 2012 02:06 PM (UTC)
Message
The simplest way is to duplicate the plugin and edit the second one to have a new ID number.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #85 on Sat 29 Dec 2012 12:45 AM (UTC)
Message
MUSHclient Edit menu -> "Generate Unique ID" will give you a plugin ID you can use. Of course in the duplicated plugin you probably need to change the triggers slightly.

- Nick Gammon

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

Posted by CincyMush   (15 posts)  [Biography] bio
Date Reply #86 on Sat 29 Dec 2012 02:58 AM (UTC)
Message
Thanks for the great info worked perfect. Now one other question I have turned the echo off on the second window I created because it is just noisy stuff like fishing feed back but even though they are flagged as omit from output and echo is off my prompt is cycling on each action which then defeats the purpose of moving the info to another window. Is there a good way to keep my prompt from cycling?
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #87 on Sat 29 Dec 2012 06:25 AM (UTC)
Message
What do you mean by cycling exactly? Repeating?

- Nick Gammon

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

Posted by CincyMush   (15 posts)  [Biography] bio
Date Reply #88 on Sat 29 Dec 2012 06:31 PM (UTC)
Message
I was getting a blank line and a new prompt in my main window for every entry redirected to the miniwindow. I added the plugin to eliminate the blank lines but now need to figure out how to gag my prompt so it doesn't repeat after these actions.
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #89 on Sat 29 Dec 2012 10:10 PM (UTC)
Message
I would suggest making a trigger that matches the prompt, compare it to the previous one, and if the same, do nothing. Otherwise echo the prompt. Of course, you omit the original one from output.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


105,575 views.

This is page 6, subject is 9 pages long:  [Previous page]  1  2  3  4  5  6 7  8  9  [Next page]

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]