My code started to get really weird, so I've started over from scratch..
LINK TO CURRENT CODE BELOW
http://textuploader.com/dmhdj
My current issues is this
Run-time error
Plugin: Aardwolf_Health_Bars (called from world: Dark Wizardry
Function/Sub: DoNextSimpleBar called by trigger
Reason: processing trigger "" when matching line: "<1818/1818 hp 9084/9084 m 2566/2566 mv>"
[string "Plugin: Aardwolf_Health_Bars"]:81: attempt to index local 'wildcards' (a nil value)
stack traceback:
[string "Plugin: Aardwolf_Health_Bars"]:81: in function <[string "Plugin: Aardwolf_Health_Bars"]:79>
and of course, every time the prompt hits, I get this "Trigger function "DoNextSimpleBar" not found or had a previous error."
I've set the wildcard values and triggering system in the following way.
<triggers>
<trigger
enabled="y"
match="^\<(\d+)\s*\/(\d+)\s*hp (\d+)\s*\/(\d+)\s*m (\d+)\s*\/(\d+)\s*mv>"
regexp="y"
script="DoNextSimpleBar"
sequence="100"
>
</trigger>
</triggers>
I've taken the triggering mechanism from Nick's miniwindows, and I've used it here. Instead of using the script "do_prompt", I've asked it to do the script "DoNextSimpleBar", which is what I thought fiendish said, basically (use his drawing script, which is what I wanted anyway)
I've not removed all of the GMCP values yet, but I'm trying to get a working model with HP/MANA/MOVE, and go from there.
The code started with this,
DoNextSimpleBar("Health", gmcp_char.vitals.hp, gmcp_char.maxstats.maxhp)
DoNextSimpleBar("Mana", gmcp_char.vitals.mana, gmcp_char.maxstats.maxmana)
DoNextSimpleBar("Moves", gmcp_char.vitals.moves, gmcp_char.maxstats.maxmoves)
and went to this...
DoNextSimpleBar("Health", hp , max_hp)
DoNextSimpleBar("Mana", mana, max_mana)
DoNextSimpleBar("Moves", move, max_move)
Another part I've changed is here...
function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label)
txt = ""
if (showBar[bar][2] == true) then
local num_val = tonumber(val)
local num_maxval = tonumber(maxval)
if showLabels == 1 then
if stacked == 1 then
WindowText(win, font_id, stacked_label or showBar[bar][1], xpos, ypos, 0, 0, showBar[bar][4], false)
else
xpos = xpos + WindowText(win, font_id, unstacked_label or showBar[bar][3], xpos, ypos, 0, 0, showBar[bar][4], false)
end
end
I've added this line RIGHT after function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label)
hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
move, max_move = tonumber (wildcards [5]), tonumber (wildcards [6])
and I also added "wildcards" to the end of
function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label)
I ended up with function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label, wildcards)
hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
move, max_move = tonumber (wildcards [5]), tonumber (wildcards [6])
txt = ""
if (showBar[bar][2] == true) then
local num_val = tonumber(val)
local num_maxval = tonumber(maxval)
if showLabels == 1 then
if stacked == 1 then
WindowText(win, font_id, stacked_label or showBar[bar][1], xpos, ypos, 0, 0, showBar[bar][4], false)
else
xpos = xpos + WindowText(win, font_id, unstacked_label or showBar[bar][3], xpos, ypos, 0, 0, showBar[bar][4], false)
end
end
if num_maxval and num_val then
if flip then
val = tostring(num_maxval-num_val)
num_val = tonumber(val)
end
if overlay_numbers == 1 or overlay_numbers == 3 or (graphicalMode == 0 and overlay_numbers ~= 2) then
maxlen = math.max(#maxval, #val)
txt = string.lpad(val, maxlen, ' ').."/"..string.rpad(maxval,maxlen,' ')
end
if overlay_numbers == 2 or overlay_numbers == 3 then
txt = txt..((overlay_numbers == 3 and " (") or "")..string.lpad(string.format('%u',100*num_val/num_maxval).."%",4,' ')..((overlay_numbers == 3 and ")") or "")
end
end
without changing anything else. (I know that's not the end of the function, but I've not changed anything else)
Maybe that's not the correct order, maybe I don't understand that part, or maybe I've put the wildcards part in the wrong part of the script?
I appreciate working with me on this... |