Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-25-18, 12:10 AM   #1
Xancepants
A Deviate Faerie Dragon
Join Date: Oct 2014
Posts: 17
LUA for HP % on Nameplates?

Hello all!
I've come across this bit of code that puts the % of HP in the center of Nameplates. However, now it starts throwing major errors when you try to type anything in chat and it seems to cause an infinite taint. I was wondering if anybody might know of a way to fix this bit of code so that it works with todays version of WoW? Or possibly even come up with a new way to achieve this? Any help is appreciated, and thank you in advance!


Here is the Lua:

Lua Code:
  1. CreateFrame('frame'):SetScript('OnUpdate', function(self, elapsed)
  2.   for index = 1, select('#', WorldFrame:GetChildren()) do
  3.         local f = select(index, WorldFrame:GetChildren())
  4.         if f:GetName() and f:GetName():find('NamePlate%d') then
  5.           f.h = select(1, select(1, f:GetChildren()):GetChildren())
  6.           if f.h then
  7.          if not f.h.v then
  8.            f.h.v = f.h:CreateFontString(nil, "ARTWORK")  
  9.            f.h.v:SetPoint("CENTER", 5, 0)
  10.            f.h.v:SetFont(STANDARD_TEXT_FONT, 9, 'OUTLINE')
  11.          else
  12.            local _, maxh = f.h:GetMinMaxValues()
  13.            local val = f.h:GetValue()
  14.            f.h.v:SetText(string.format(math.floor((val/maxh)*100)).." %")
  15.          end
  16.           end
  17.         end
  18.   end
  19. end)



Here is the Error that Bug Sack is logging:

2269x Custom Settings\Custom Settings.lua:88: Attempt to access forbidden object from code tainted by an AddOn
[C]: in function `GetName'
Custom Settings\Custom Settings.lua:88: in function <Custom Settings\Custom Settings.lua:85>

Locals:
(*temporary) = <unnamed> {
0 = <userdata>
}
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » LUA for HP % on Nameplates?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off