MUSHclient LUA plugins that use a "Dummy" World - HELP!!

Posted by Zantiln on Fri 07 Nov 2008 08:17 PM — 4 posts, 19,308 views.

#0
Does anyone know of any examples or VERY simple plugins that I could look at to help me create my own plugin to display, for example, the real-time value of my health points, updated every second or so?

I tried to look at the source code for the Aardwolf_Stats plugin, but there is too much going on for me to understand what does what.

I have already created a "Dummy" World in my MUSHclient using the quick connect feature, and its setup for IP 0.0.0.0. Now if I can just find a very simplified .XML file or code sample that will:

1 - Capture my current health points (similar to how Aardwolf_Stats script captures your stats)
2 - Clear all the text in the "Dummy" World
3 - Display the captured value in the "Dummy" World
4 - Repeat steps 1 through 3 every second

Eventually, if I can learn how to do the above, I would like to create a plugin that will monitor and display multiple stats, spells, and other info in real-time.

Can anyone help? Thanks in advance...
Australia Forum Administrator #1
See http://mushclient.com/faq point 23 for some details about that.

You could use DeleteOutput to remove the output window contents (on the dummy world, not the main world).

http://www.gammon.com.au/scripts/doc.php?function=DeleteOutput
Australia Forum Administrator #2
You might be much better off using miniwindows rather than a dummy world. This saves mucking around making the world, and sending stuff to it.
Australia Forum Administrator #3
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>