Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Message
| The plugin below is intended to "hit you between the eyes" with important warning messages - see screen shot in the next message.
To communicate with the plugin, just type something commencing with "combat_message". In the example screen shot, I typed:
combat_message trouble brewing
The specified message appears in yellow, in a red box with a yellow border, in the middle of the screen. A sound is played to draw your attention to it. The box disappears after 5 seconds, or if replaced by a different message.
MUD output continues to scroll underneath the warning message, so you can keep playing normally. You can configure the font size and colour to be used for the message.
To change the length of time the message stays visible, change the line:
... in the plugin to some other value (default is 5 seconds).
As the plugin uses an alias to display the message, any other plugin or script can cause the message to appear by simply using world.Execute to send that message to the command processor.
For example:
world.Execute ("combat_message Starting combat!")
To use, save between the lines as Combat_Text.xml, and then use File menu -> Plugins to load that file as a plugin.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- MuClient version 4.37 -->
<muclient>
<plugin
name="Combat_Text"
author="Nick Gammon"
id="4de91eaa2624f202c4bb6837"
language="Lua"
purpose="Shows messages in the middle of the output window"
date_written="2009-02-08 14:00"
requires="4.37"
version="1.0"
>
</plugin>
<!-- Aliases -->
<aliases>
<alias
script="combat_message"
match="combat_message *"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Timers -->
<timers>
<timer script="remove_message"
second="5.00"
active_closed="y"
name="remove_message"
>
</timer>
</timers>
<!-- Script -->
<script>
<![CDATA[
-- configuration
-- font
FONT_NAME = "Arial Black"
FONT_SIZE = 30
TEXT_COLOUR = ColourNameToRGB ("yellow")
BACKGROUND_COLOUR = ColourNameToRGB ("darkred")
-- where to put the window
WINDOW_POSITION = 12 -- centered
OFFSET = 5 -- gap inside box
-- what sound to play
SOUND_FILE = "/Windows/Media/Windows XP Balloon.wav"
-- alias goes here
function combat_message (name, line, wildcards)
message = wildcards [1]
width = WindowTextWidth (win, "f", message)
-- make the window
WindowCreate (win, 0, 0,
width + (OFFSET * 2),
font_height + (OFFSET * 2),
WINDOW_POSITION, 0,
BACKGROUND_COLOUR) -- create window
WindowText (win, "f", message, OFFSET, OFFSET, 0, 0, TEXT_COLOUR)
WindowRectOp (win, 1, 0, 0, 0, 0, TEXT_COLOUR)
-- show window
WindowShow (win, true) -- show it
-- play a warning sound
Sound (SOUND_FILE)
-- enable and reset the timer which removes the message
EnableTimer ("remove_message")
ResetTimer ("remove_message")
end -- end combat_message
-- here to remove the message
function remove_message ()
WindowShow (win, false)
end -- remove_message
-- startup stuff
win = GetPluginID () -- get a unique name
-- make the window
WindowCreate (win, 0, 0, 0, 0, WINDOW_POSITION, 0, 0x000000) -- 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
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|