You don't need to define the function twice. In fact, the first one won't work, because you're trying to assign %1, exactly what you -don't- want in the script file. It only works because you're creating a new function right after that with the same name, that DOES do the right thing, so the first one never gets used.
As for the second question, I assume you want to replace your prompt with "h:50%, m:38%, e:99%, p:64%, en:10%, w:83%"? It's a little more in-depth. You'd need to match on the prompt and catch the health values - you're doing this already - but set the Omit From Output checkbox. Or if you want to exit the <trigger> tag directly, add omit_from_output="y" into that list of options.
Then you'd need to have stored your maximum values somewhere. The info on the prompt only tells you how much you -have-, not how much you could have maximum. And we need that to produce a percentage. For now, you could do that yourself by setting variables called "max_h", "max_m", etc. in MUSHclient, and then referring to those from the script.
Here's an example, assuming you've set those max values:
function prompt (name, line, matches, styles)
SetVariable ("current_h", matches [1])
SetVariable ("current_m", matches [2])
SetVariable ("current_e", matches [3])
max = {} -- create an empty table
max.h = GetVariable("max_h")
max.m = GetVariable("max_m")
-- et cetera
percents = {} -- create an empty table
-- calculate the percentage value
percents.h = (matches[1] / max.h) * 100
percents.m = (matches[2] / max.m) * 100
-- et cetera
-- finally, echo your new prompt
-- it's not coloured, but it's not a
-- terribly basic thing to do
newprompt = "h:" .. percents.h
.. " m:" .. percents.m
-- et cetera
Note(newprompt)
end -- function
The code is un-tested, and I think there might be a problem with decimal values you don't want (like "h:66.66666666" instead of "h:66"). Still, that's how you might do it.