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 ➜ Plugin to show combat warnings in a big, obvious, box

Plugin to show combat warnings in a big, obvious, box

Posting of new messages is disabled at present.

Refresh page


Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Sun 08 Feb 2009 02:41 AM (UTC)

Amended on Sun 08 Feb 2009 02:50 AM (UTC) by Nick Gammon

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:


second="5.00" 


... 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

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 08 Feb 2009 02:41 AM (UTC)
Message

Example of it in operation:


- Nick Gammon

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

Posted by Keberus   (31 posts)  Bio
Date Reply #2 on Thu 12 Mar 2009 11:29 AM (UTC)
Message
I know that the last post in this thread is old, but I just started using MUSHclient (after I realized how sweet it was from hearing about it over at MudBytes, etc). Anywho, I thought it would be cool to modify the combat_message to work like a way to notice a new message when it pops up via ooc or something. My trigger is setup like:


Trigger:
*(OOC) *

Send:
world.Execute ("combat_message (OOC) %2")


And here's the modified code for the combat_message 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 = 10
TEXT_COLOUR = ColourNameToRGB ("white")
BACKGROUND_COLOUR = ColourNameToRGB ("blue")


-- where to put the window
WINDOW_POSITION = 6  -- upper RH corner
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>


Which works, but then it also sends the line to the mud, which of course cause the mud to go 'Huh?'. So is there a way I can use a trigger to send info to the combat_message plugin, but not send it to the mud as well?


Thanks in advance,
KeB
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #3 on Thu 12 Mar 2009 04:53 PM (UTC)
Message
Why does it send anything to the mud?

You have a trigger, which fires on ooc chat. When it fires, it uses world.Execute() to call the plugins combat_message alias. Since it matches an alias, it should not be getting executed anymore, and I don't see any Send() commands either. So either I am missing something obvious, or you may be missing something in your explanation.
Top

Posted by Keberus   (31 posts)  Bio
Date Reply #4 on Thu 12 Mar 2009 07:23 PM (UTC)
Message
Let's see, not sure if I missed much, but in the Send to box, I've tried Script (after omit) and Script, because they are the only two that work, and create the box, but they still send up sending a message to the mud.

Example.

In mud, I type:
Quote:

ooc test


Top RH corner shows
Quote:

(OOC) Keberus: Test


But the mud also gets sent
Quote:

combat_message (OOC) Keberus: test


As input, like its a command. So, I'm trying to get it to stop doing the part about sending to the mud as input. Hope this helps to clarify things.


Thanks,
Keb
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 12 Mar 2009 08:37 PM (UTC)
Message
Quote:

Trigger:
*(OOC) *

Send:
world.Execute ("combat_message (OOC) %2")


Please show the actual trigger. See http://mushclient.com/copying

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #6 on Thu 12 Mar 2009 08:40 PM (UTC)
Message
For interest, the changes he made, which don't seem to be relevant to the problem, are:


*** 52,64 ****
  
  -- 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
--- 52,64 ----
  
  -- font
  FONT_NAME = "Arial Black"
! FONT_SIZE = 10
! TEXT_COLOUR = ColourNameToRGB ("white")
! BACKGROUND_COLOUR = ColourNameToRGB ("blue")
  
  
  -- where to put the window
! WINDOW_POSITION = 6  -- upper RH corner
  OFFSET = 5  -- gap inside box
  
  -- what sound to play

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #7 on Thu 12 Mar 2009 08:43 PM (UTC)
Message
Quote:

world.Execute ("combat_message (OOC) %2")


You might want to consider Lua long quotes. This would fail if someone chatted with a " in the string. Thus it could be:



world.Execute ([==[combat_message (OOC) %2]==])

- Nick Gammon

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

Posted by Keberus   (31 posts)  Bio
Date Reply #8 on Thu 12 Mar 2009 09:32 PM (UTC)
Message
Okay, here's the trigger from the copy method.


<triggers>
  <trigger
   enabled="y"
   match="*(OOC) *"
   match_text_colour="y"
   send_to="12"
   sequence="100"
   text_colour="11"
  >
  <send>world.Execute ([==[combat_message (OOC) %2]==])</send>
  </trigger>
</triggers>


I switched to the Lua long quotes like you suggested. Of course I still have the issue that it sends the text to the MUD, but thanks for the suggestion none the less.
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #9 on Thu 12 Mar 2009 09:37 PM (UTC)

Amended on Thu 12 Mar 2009 09:38 PM (UTC) by Worstje

Message
Sorry for the slight derail, but Nick, I thought your send-field wildcards were smart in nature? I recall reading through the source and seeing you apply 'smart' escaping depending on the language in question, and I am sure you escaped " in the case Lua was the scripting language.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #10 on Fri 13 Mar 2009 (UTC)
Message
Oops, yes you are right. Probably best to put it back how it was, or you might see \" in the text. :)

I tested your trigger and it worked as expected, and did not send anything to the MUD. Try turning on Game menu -> Trace. Perhaps another trigger is firing as well?

- Nick Gammon

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

Posted by Keberus   (31 posts)  Bio
Date Reply #11 on Fri 13 Mar 2009 02:12 AM (UTC)
Message
Alright, messing with a few things, I found that if I disable the server from echo'ing my commands the trigger won't work at all. And for some reason the client doesn't seem to echo anything I type once logged in (yes I have tried checking and unchecking that echo input thing 15x). I also set the color to a bright yellow, so its not that I couldn't see it, if it was working, it's just not working. Is there something I need to change on the server for it to work.

Thanks,
KeB
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #12 on Fri 13 Mar 2009 03:49 AM (UTC)
Message
This is all interrelated, I guess. Try turning trace on, I suspect more is going on than you think.

You should be able to test without even being connected. Go into Game menu -> Test Trigger. Then enter in the box:


\0A
\1B[33m(OOC) Keberus: Test
\0A


That should cause the trigger to match and the message to appear. Make sure you have the plugin installed and enabled, or the message will simply be sent to the MUD.

- Nick Gammon

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

Posted by Keberus   (31 posts)  Bio
Date Reply #13 on Fri 13 Mar 2009 05:47 AM (UTC)
Message
Okay, I noticed that after I uninstalled and re-installed MUSHclient the echoing worked. So, I started checking it after every plugin I used, and I don't know if it's supposed to do it or whatever, but as soon as I installed and enabled the ANSI_log plugin my commands stopped echoing. I found if I simply removed that plugin everything worked exactly how I wanted it to.

Thanks for all the help,
KeB
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #14 on Fri 13 Mar 2009 08:19 AM (UTC)
Message
Ah, that'd do it. A quick look into the plugin explains why this happens, too.

<aliases>
  <alias
   name="ansi_log"
   script="LogCommand"
   match="^.*$"
   enabled="y"
   omit_from_log="y"
   omit_from_output="y"
   regexp="y"
   keep_evaluating="y"
   sequence="5"
  >
  <send>%0</send>
  </alias>
</aliases>


No send_to has been specified, so it sends to the world at all times. However, it also has keep_evaluating turned on, which means your trigger also gets fired.

Clearly, this is an ancient plugin (v3.42 was used to generate it on 'Friday, July 25, 2003, 10:50 AM'). It is easy to amend the behaviour to no longer cause trouble for you. I'll walk you through it really briefly, since I'm sure Nick might want to make other adjustments himself and I don't have time to work it out with the various settings the plugin itself supports. This assumes that -all- sent output should be shown in the log (it will echo SendNoEcho() things due to how it works).

1. Get rid of the alias.
2. Add an OnPluginSent(text) sub like the following at the end of the scripting section:

sub OnPluginSent(text)
  WriteLog ANSI(0) & ANSI(1) & ANSI(33) & text & vbCrLf
end sub


This will very roughly log all your commands in bright, bold yellow to the log. If you are really addicted to your ANSI logging, this should put it back to work for you till Nick has time to update the script with some new version of MUSHclient some time.
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.


46,946 views.

Posting of new messages is disabled at present.

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.