XP Counter for MUSHclient

From Discworld MUD Wiki
Jump to: navigation, search

This is an XP Counter for MUSHclient by Beale and Sciante.

Copy the following into a notepad file, or similar:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
  <!ENTITY trigger_match 
   "(?:> |)Hp: (\d+) ?\((\d+)\) +(?:Gp: (\d+) ?\((\d+)\)) +(?:Xp: (\d+))($|  Burden: (\d+\%)$)"> 
]>   
<!-- Saved on Monday, April 28, 2003, 9:53 AM -->
<!-- MuClient version 3.41 -->

<!-- Based on the Plugin "Health_Bar" (by Nick Gammon) generated by Plugin Wizard -->
<!-- Rewritten in LUA by Beale (Ian Kirker) -->
<!-- Modified by Sciante (Magnus Lundborg) to show xp and time statistics -->
<!-- and to work properly using wine in Linux (sorry that the bars had to go) -->
<!-- Slightly inspired by the Timer plugin by Nick Gammon -->
<!-- Sux2b VBScript. -->
<!-- This version has been updated to account for the addition of burden to 'score brief'.-->

<!--
You will probably need to customise the trigger to match your MUD.

See ENTITY line near top of file. The above trigger will match on:

  Hp: x (X) Gp: y (Y) Xp: z

where x, X, y, Y and z are numerical values.
-->

<muclient>
<plugin
   name="Statistics_Bar"
   author="Magnus Lundborg"
   id="a2af5216d68563401888e01e"
   language="Lua"
   purpose="Shows HP, GP, XP as well as using a timer to calculate xp gain"
   date_written="2003-04-28 09:50:05"
   date_modified="2005-05-05 16:00"
   requires="3.49"
   version="1.2"
   >
<description trim="y">
<![CDATA[
Install this plugin to show an info bar with HP, GP, 
and Experience points. You also get information about xp gain over
a given time period, which can be reset by typing "resettimer".

You need your score line to display the appropriate information,
naturally.

Customise the plugin if you want to match a different sort of score line.

To see this message, type: Statistics_Bar:help

]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   match="&trigger_match;"
   name="InfoBar"
   regexp="y"
   script="DoPrompt"
   sequence="100"
  >
  </trigger>
</triggers>


<!--  Aliases  -->

<aliases>
  <alias
   script="TimerToZero"
   match="resettimer"
   enabled="y"
   sequence="100"
  >
  </alias>
</aliases>



<!--  Script  -->


<script>
<![CDATA[

local time=0
local basexp
local xp
local mins

--
--  Called by alias to zero timer
--
function TimerToZero (sName, sLine, wildcards)
	time = 0
	world.InfoClear()
	world.Info("Timer and xp counter reset. Restarted on next score output.")
end


function DoPrompt(sName, sLine, wildcards)

	local xpdiff
	local timediff
	local str

	xp=wildcards[5]

	if time==0 then
		time = world.GetConnectDuration()
		basexp=xp
	end


	xpdiff=xp-basexp

	timediff = (world.GetConnectDuration()) - time

	mins=(timediff/60)
	mins=math.floor(mins*10+0.5)/10

	--This is the font used in the text.
	sFont="Arial"
	
	--Clear the Infobar.
	world.InfoClear()
	
	world.Info("HP: " .. wildcards[1] .. " \(" .. wildcards[2] .. "\) ")
	world.Info("  GP: " .. wildcards[3] .. " \(" .. wildcards[4] .. "\) ")
	world.InfoFont(sFont, 12, 1)	
	world.Info("  XP: " .. xp)
	world.Info("           " .. xpdiff .. " xp gained in " .. mins .. " minutes")
	world.Info("         Average xp/hour: " .. (math.floor ((xpdiff/(timediff/3600))*10+0.5))/10)
	world.Info("                  To reset the time and xp counter type \"resettimer\"")
	
end

--
--  Do this once
--
world.ShowInfoBar(1)



]]>
</script>

</muclient>
Save the file as:
statistics_bar-lua.xml

in c:\Program Files\MUSHclient\worlds\plugins\ (or where ever your plugins for MUSHclient are located.)

Next, in MushClient select 'File' from the top menu, then 'Plugins'. Hit the Add button, click on statistics_bar-lua.xml to select it, then hit open. The file should now be listed on your plugins window. Now type score brief into the mud, if it's working some extra text should show up in your info bar near the bottom of the Mushclient window. To track your xp, the trigger needs you to use the "score brief" command frequently in order to make the calculations. It's a good idea to add it to the beginning and end of your idle aliases. Be sure your info bar is being displayed: Select View from the top menu, and Info Bar should be checked.

If you ever want to restart the timer, go to File, then Plugins, then hit the ReInstall button while the script name is highlited. This is essential after spending xp. (or simply type resettimer into the mud)

To adjust the font size (which may be necessary, depending on how big your window is), modify the "12" in this line:

	world.InfoFont(sFont, 12, 1)