Register forum user name 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Modifying statistics bar by Magnus Lundborg

Modifying statistics bar by Magnus Lundborg

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Haj   (3 posts)  Bio
Date Sun 28 Apr 2013 07:39 AM (UTC)

Amended on Sun 28 Apr 2013 07:48 AM (UTC) by Haj

Message
Hi, I tried messing around with this and I could not figure it out using the following URL http://www.lua.org/pil/20.2.html. I am by no means any good at writing plugins and would appreciate some help. I am trying to modify the code below to now trigger off of this HP: 1548 (1548) GP: 255 (345) XP: 154831 A: evil B: 37%



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
  <!ENTITY trigger_match 
   "(?:> |)Hp: (\d+) ?\((\d+)\) +(?:Gp: (\d+) ?\((\d+)\)) +(?:Xp: (\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 -->
<!-- This version uses a slightly smaller bar to fit on most screens -->
<!-- Sux2b VBScript. -->


<!--
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, 11, 1)	
	world.Info("  XP: " .. xp)
	world.Info("      " .. xpdiff .. " xp in " .. mins .. " minutes")
	world.Info("      Av. xp/hour: " .. (math.floor ((xpdiff/(timediff/3600))*10+0.5))/10)
	world.Info("        \"resettimer\" resets the time and xp counter")
	
end

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



]]>
</script>

</muclient>



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.


6,726 views.

It is now over 60 days since the last post. This thread is closed.     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.