3

I'm in the midst of making a WoW addon for RP'ers and I have come across a bit of a difficult problem. I've written up this addon to have a Health indicator, and a Barrier indicator. The Barrier takes any damage before damage is applied to health, and even carries over if there is a remainder

Bob has 3 Barrier and 10 HP, he takes 4 damage so he now has 9 HP.

I've decided to add another layer of protection, which is Armor. This armor would act as another static healthbar that protect the players HP value.

So Bob has 3 Barrier, 5 Armor and 10 HP. He then takes 4 damage, and now has 0 Barrier, 4 Armor and 10 HP. Then he takes 5 Damage, and now has 0 Barrier, 0 Armor and 9 HP.

All of this would be typed out into the chat of whatever group was appropriate, like this

I'm having issues implimenting this armor bar, this is what I have so far.

        apdmg = 0
        hpdmg = 0
        bdmg = 0
        if TempHP >=0 then hpdmg = tdmg - TempHP
            else hpdmg = tdmg - apdmg end
        if hpdmg < 0 then hpdmg = 0 end
        if apdmg < 0 then hpdmg = 0 end
        bdmg =  tdmg - hpdmg
        tdmg - ArmorPoints = apdmg
        TempHP = TempHP - bdmg
        HealthPoints = HealthPoints - hpdmg
        ArmorPoints = ArmorPoints - apdmg
        if ArmorPoints < 0 then ArmorPoints = 0 end
        if HealthPoints < 0 then HealthPoints = 0 end
        if TempHP < 0 then TempHP = 0 end
        if statsop == "True" then 
            hpinput:SetText(HealthPoints)
            armorinput:SetText(ArmorPoints)
            thpinput:SetText(TempHP) end


--apdmg = Armor point Damage
--hpdmg = Health Point damage
--bdmg = Barrier Damage
--TempHP is also a version of barrier damage.

However when i add this to the addon, and try to activate the function I get the following error message.

Note: Line 1666 is the following

block:SetScript("OnClick", function()
    C_Timer.After(1, function()
    --d20 = tonumber(roll)
    d20t = d20 + Block + DefMod
    if d20t >= DifficultyCheckDef then
        OutC = "Pass" else
    OutC = "Fail"
end

and line 1634 is simply this

apinput:SetText(ArmorPoints)
vallentin
  • 23,478
  • 6
  • 59
  • 81
Jackal
  • 31
  • 2
  • I fail to see the error message. – Dimitry Mar 30 '17 at 19:45
  • The in game screenshot posted in the bottom of the post -is- the error message that !debugger spits out – Jackal Mar 30 '17 at 19:51
  • The image didn't load for me at first. Well, apparently, `apinput` is `nil`. You should check where it is initialized. Also, 8 lines you reference as "line 1666" do not form a correct lua block, neither do I see any connection between them, the "line 1634" and the topmost snippet. – Dimitry Mar 30 '17 at 20:24
  • armorinput:SetText(ArmorPoints) end) HPTX = statsbg:CreateFontString(nil, "High", "GameTooltipText") HPTX:SetPoint("RIGHT",armorsub,"LEFT",3,0) HPTX:SetText("Armor:") HPTX:SetFont("Fonts\\FRIZQT__.ttf", 8,"OUTLINE") And the end of defining the button for armor it self is the only place where I can find ArmorInput being initialized. – Jackal Mar 30 '17 at 20:35
  • 1
    You can edit your question text. If the code you've added is the ending of "line 1666" then it is still not valid lua block (only two `end`s and three open-ing verbs) and there's still no mention of `apinput`. – Dimitry Mar 30 '17 at 20:45
  • [This](https://jsfiddle.net/ou0t2gk4/) is not an answer but I thought that the formula might help. – user7393973 Jul 17 '17 at 17:02

0 Answers0