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.
 Entire forum ➜ MUSHclient ➜ Plugins ➜ Redirect trace output to a miniwindow

Redirect trace output to a miniwindow

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


Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Thu 05 Feb 2009 05:55 AM (UTC)

Amended on Sat 07 Feb 2009 01:14 AM (UTC) by Nick Gammon

Message
Following on from my previous trace redirector (http://www.gammon.com.au/forum/?id=9217), this plugin uses the miniwindow code to show the trace output "on top of" the main MUD window. This has a couple of useful advantages:


  • It isn't hidden underneath, as a notepad window would be
  • It isn't mixed up with the MUD output, which can throw out the look of the MUD
  • It isn't omitted from output, if a trigger omits from output


The behaviour is customizable from the settings near the front (eg. window size and position).

Just install it, turn trace on, and the window will appear as soon as something traceable occurs.

Save between the lines as Trace_Window.xml and use File menu -> Plugins to load that file as a plugin.



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, February 05, 2009, 3:33 PM -->
<!-- MuClient version 4.37 -->

<!-- Plugin "Trace_Window" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Trace_Window"
   author="Nick Gammon"
   id="9c16895687a6b24f6202ac0c"
   language="Lua"
   purpose="Redirects trace to a miniwindow"
   date_written="2009-02-05 17:00"
   requires="4.37"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[

-- configuration

-- window size in pixels
WINDOW_WIDTH = 400
WINDOW_HEIGHT = 200   -- 200 is 16 lines of 9-point Lucida Console

-- font
FONT_NAME = "Lucida Console"
FONT_SIZE = 9

-- where to put the window
WINDOW_POSITION = 6  -- see below (6 is top right)

--[[
Useful positions:

4 = top left
5 = center left-right at top
6 = top right
7 = on right, center top-bottom
8 = on right, at bottom
9 = center left-right at bottom
--]]


-- colours
WINDOW_BACKGROUND_COLOUR = ColourNameToRGB ("khaki")
WINDOW_TEXT_COLOUR = ColourNameToRGB ("black")

-- offset of text from edge
TEXT_INSET = 5

-- where to store the trace line
lines = {}  -- table of recent trace lines

-- display one line
function Display_Line (line, text)

  local left = TEXT_INSET
  local top = (line - 1) * font_height
  
  WindowText (win, "f", text, left, top, WINDOW_WIDTH - TEXT_INSET, 0, WINDOW_TEXT_COLOUR)
  
end -- Display_Line

-- here on trace
function OnPluginTrace (line)

  -- blank existing window contents
  WindowRectOp (win, 2, 0, 0, 0, 0, WINDOW_BACKGROUND_COLOUR)
  
  -- remove first line if filled up
  if #lines >= max_lines then
    table.remove (lines, 1)
  end -- if 

  -- add new line, time-stamped
  table.insert (lines, os.date ("%H:%M:%S ") .. line)
  
  -- display all lines
  for k, v in ipairs (lines) do
    Display_Line (k, v)
  end -- for
  
  -- force window redisplay
  WindowShow (win,  true)  -- show it 
  
end -- end OnPluginTrace

-- hide window on removal
function OnPluginClose ()
  WindowShow (win,  false)  -- hide it
end -- OnPluginClose

-- hide window on disable
function OnPluginDisable ()
  WindowShow (win,  false)  -- hide it
end -- OnPluginDisable

-- show window on enable
function OnPluginEnable ()
  if #lines > 0 then
    WindowShow (win,  true)  -- show it
  end -- if
end -- OnPluginEnable

-- startup stuff

win = GetPluginID ()  -- get a unique name

-- make the window
WindowCreate (win, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, 
                         WINDOW_BACKGROUND_COLOUR)  -- create window
               
-- grab a font
WindowFont (win, "f", FONT_NAME, FONT_SIZE) -- define font

-- work out how high it is
font_height = WindowFontInfo (win, "f", 1)   -- height of the font  

-- work out how many lines will fit
max_lines = math.floor (WINDOW_HEIGHT / font_height)

]]>
</script>

</muclient>



- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 05 Feb 2009 05:56 AM (UTC)
Message

Example of it in operation:


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 05 Feb 2009 06:04 AM (UTC)
Message
With a bit of work with matching the start of the trace line you could colour lines individually (eg. if starts with "Matched trigger" show the line in blue).

- Nick Gammon

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


13,695 views.

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.