Quantcast Auras.PostCreateIcon? - WoWInterface
Thread Tools Display Modes
12-06-17, 11:35 AM   #1
Naisz
A Deviate Faerie Dragon
 
Naisz's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 12
Auras.PostCreateIcon?

Hello folks!

At first id like to thank everyone for the initial help they gave me on here. My layout is coming together the way i want to. But sadly im running into a Problem again with displaying Auras, or rather setting the TexCoord of the related icon.

this is located inside another .lua file
Lua Code:
  1. local _,ns = ...
  2.  
  3. [-unrelated code-]
  4.  
  5. ns:UpdateAuraIcon = function(element, button)
  6.          button.overlay:SetAlpha(0)
  7.          button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  8.      button.icon:SetDrawLayer('ARTWORK')
  9. end

inside my Layout file im doing
Lua Code:
  1. local Auras = CreateFrame('Frame', nil, self)
  2.                 Auras.gap = true
  3.                 Auras.size = 20
  4.                 Auras:SetHeight(60)
  5.                 Auras:SetWidth(200)
  6.                 Auras:SetPoint('BOTTOMLEFT', self.Health, 'TOPLEFT', 0, 0)
  7.                 Auras.initialAnchor = 'BOTTOMLEFT'
  8.                 Auras['growth-x'] = 'RIGHT'
  9.                 Auras['growth-y'] = 'UP'
  10.                 Auras.numBuffs = cfg.numBuffs
  11.                 Auras.numDebuffs = cfg.numDebuffs
  12.                 Auras.spacing = 1
  13.                 Auras.showStealableBuffs = true
  14.  
  15.                 Auras.PostCreateIcon = ns.UpdateAuraIcon
  16.                 Auras.PostUpdateIcon = ns.PostUpdateIcon
  17.                 self.Auras = Auras

For some reason, ns.UpdateAuraIcon doesnt trigger as far as i experienced

Other stuff inside the namespace, for example cfg.numBuffs is working fine. But it feels like it isnt triggering the function outside the .lua-file but inside the namespace? Am i doing something wrong regarding functions inside the namespace?

Thanks in advance and greetings!

EDIT:

I solved the issue by doing

lua Code:
  1. function ns:UpdateAuraIcon(button)

i dont know why the other option didnt work, if someone knows. please feel free to explain

Last edited by Naisz : 12-06-17 at 12:47 PM. Reason: SOLVED
  Reply With Quote
12-06-17, 01:21 PM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,024
Code:
ns:UpdateAuraIcon = function(element, button)
Isn't valid Lua, so that's why it didn't work. It should be:
Code:
ns.UpdateAuraIcon = function(element, button)
Notice the dot instead of semi-colon

Your new function definition works because:
Code:
function ns:UpdateAuraIcon(button)
Is the same as:
Code:
function ns.UpdateAuraIcon(ns, button)
__________________
「貴方は1人じゃないよ」
  Reply With Quote
12-06-17, 03:51 PM   #3
Naisz
A Deviate Faerie Dragon
 
Naisz's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 12
Okay thanks

I thought that the colon is referring to functions, like when setting Properties or Textures on specific frames.
But i guess, that ns.<functionname> then refers to the name of the function inside the namespace rather than a function inside the namespace.

Thanks alot haste!
  Reply With Quote
12-06-17, 04:04 PM   #4
Kanegasi
A Chromatic Dragonspawn
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 176
The colon in Lua is essentially shorthand for passing "self", or "this" as it used to be called. When using the colon, you're telling the function you're calling to automatically accept the object before the colon as the first argument. Without the colon, you're just calling the function itself. The dot is irrelevant here, it's just a way to access the function within the table. This can be confusing at times due to WoW's frame objects and the inherit functions that live in a frame's table.

Adding to the last function example of Haste's reply, this is also the same:

Code:
function ns["UpdateAuraIcon"](ns, button)
  Reply With Quote
12-07-17, 03:27 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,024
Originally Posted by Naisz View Post
But i guess, that ns.<functionname> then refers to the name of the function inside the namespace rather than a function inside the namespace.
No, function tbl:func() is just syntactic sugar for tbl.func = function(self). Just like calling tbl:func() is syntactic sugar for tbl.func(tbl). You can read more about Lua's function definitions here.

Originally Posted by Kanegasi View Post
Code:
function ns["UpdateAuraIcon"](ns, button)
That's not valid Lua, unless you meant to call the function. In that case you have to remove function from the line.
__________________
「貴方は1人じゃないよ」
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Auras.PostCreateIcon?

Thread Tools
Display Modes

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