Nick Gammon said:
I always find it helps to put in debugging print statements. Perhaps the values are 100 times what you expect, or one is missing, or something?
Results of the printing: (printed added before what was printed)
hp
HP:306/306 SP:238/238 EP:111/155
printed HP: 306/306 current/max
printed SP: 238/238 current/max
printed EP: 111/155 current/max
>
hpp
HP:100% SP:100% EP:71%
printed HP:306/306%100
printed SP:238/238%100
printed EP:155/155%71
printed HP: 306/306 current/max
printed SP: 238/238 current/max
printed EP: 155/155 current/max
Modifications to DoGauge:
print (sPrompt .. current .. "/" .. max .. " current/max")
Modifications to do_prompt_percent:
print ("HP:" .. hp .. "/" .. max_hp .. "%" .. hpp)
print ("SP:" .. sp .. "/" .. max_sp .. "%" .. spp)
print ("EP:" .. ep .. "/" .. max_ep .. "%" .. epp)
So, do_prompt_percent is the problem... it's catching the right value for the percentage (71), but it's not doing the math right.
function do_prompt_percent (name, line, wildcards)
hpp = tonumber (wildcards [1])
spp = tonumber (wildcards [2])
epp = tonumber (wildcards [3])
hp = max_hp * ( hpp / 100 )
sp = max_sp * ( spp / 100 )
ep = max_ep * ( spp / 100 )
print ("HP:" .. hp .. "/" .. max_hp .. "%" .. hpp)
print ("SP:" .. sp .. "/" .. max_sp .. "%" .. spp)
print ("EP:" .. ep .. "/" .. max_ep .. "%" .. epp)
draw_the_bars ()
end -- do_prompt_percent
Ideas?
EDIT: changed that middle part to
hp = math.floor(max_hp * (hpp / 100))
sp = math.floor(max_sp * (spp / 100))
ep = math.floor(max_ep * (spp / 100))
Doesn't change the results, but I don't want any decimal values gumming it up.
EDIT2: I have decided to, for now, scrap the idea of making the background transparent. It would be nice, but without the background it would get quite messy as text appeared beneath the gauges. Plus, I can't do the blend thing, which seems to be what people were wanting actually XD |