Posted by
| Nick Gammon
Australia (23,000 posts) bio
Forum Administrator |
Message
| To get you started, here is a simple plugin that shows the current exits (in a miniwindow). It simply uses a trigger that matches the exits line, and when found, makes a window in the top-right corner to show that, so you can always see where the exits are.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Show_Exits"
author="Nick Gammon"
id="c6b565073f07ed0679e13d16"
language="Lua"
purpose="Shows the current exits"
date_written="2008-11-08"
requires="4.34"
version="1.0"
>
<description trim="y">
<![CDATA[
Shows the current exits in a miniwindow.
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="Exits: *"
script="exits_line"
sequence="100"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
-- configuration
background_colour = 0xE7FFFF
text_colour = 0x000000
font_name = "FixedSys"
function Display_Line (line, text, id, colour)
local left = 5
local top = (line - 1) * font_height
WindowText (win, id, text, left, top, 0, 0, colour)
end -- Display_Line
function exits_line (name, line, wildcards, styles)
width = WindowTextWidth (win, font_id, line)
-- recreate the window the correct size
WindowCreate (win,
0, 0, -- left, top (auto-positions)
width + 10, -- width
font_height + 5, -- height
6, -- auto-position: top right
0, -- flags
background_colour)
Display_Line (1, line, font_id, text_colour)
WindowShow (win, true)
end -- exits_line
function OnPluginInstall ()
win = GetPluginID ()
font_id = "fn"
-- make win so I can grab the font info
WindowCreate (win,
0, 0, 1, 1, -- 1 x 1 pixel
1, -- position - irrelevant
0, -- flags
0) -- background colour
check (WindowFont (win, font_id, font_name, 8)) -- normal
font_height = WindowFontInfo (win, font_id, 1) -- height
end -- OnPluginInstall
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|