Altering Nick Gammons "Improved Health Bar" plugin to work with Midkemia Online

Posted by Kaimarae on Mon 23 May 2011 06:21 AM — 7 posts, 27,183 views.

#0
Hey there.

My mission currently is to get Nick's health bar plugin to work for my prompt, which is:

935h, 236e, 1033m xb A:50% -


and I'm matching it with this:

^(\d+)h, (\d+)e, (\d+)m x?b?.*$


I sort of understand how it all works. My issue is my prompt doesn't give me a current/max display. Just the current. I already have a variable that tracks my max hp (for use in a info bar display). I'm sure it's possible, but I don't know how to get the plugin to use my MaxHealth variable instead of the local max_hp.

For the sake of clarity, this is an extract from the .xml I'm currently using, cut down to size for the post (I took out the bits I could see regarding the Move variables and gauge as I don't have movement points):


function do_prompt (name, line, wildcards)

  local hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
  local mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
    
  local hp_percent = hp / max_hp
  local mana_percent = mana / max_mana


Instead of max_hp taking it's value from a wildcard I want it to either replace it or get it to get it's value from an existing variable.

Currently, when I enable it, it just says
Quote:
Trigger function "do_prompt" not found or had a previous error.


Thanks in advance guys :]
Australia Forum Administrator #1
I don't know why you got the error without seeing more of it, but to get the maxmima just change it to something like:


  local hp, max_hp = tonumber (wildcards [1]), 
                     tonumber (GetVariable ("MaxHealth"))


Ditto for the other one(s).

Then of course wildcard 3 becomes wildcard 2 (because you don't have the maximum).
#2
Altered that. No idea if it works as I'm still getting the error.

This is the whole of the .xml:

http://pastebin.com/xSejVybc
Germany #3
Doesn't Midkemia Online support GMCP? That should be cleaner and easier than capturing the data from the prompt.
#4
Yes, it does and I have a GMCP plugin installed, but currently I'm still figuring things out. After I have it up and running I'll look at better ways to go about it.
#5
I'm still getting the

Quote:
Trigger function "do_prompt" not found or had a previous error.


error whenever I try and use it. Really want to fix it, but I have no idea what's going on. :/
Australia Forum Administrator #6
Do you see any error message? What are they? Which version of MUSHclient are you using?