Thread Tools Display Modes
08/23/14, 01:52 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
LibStub Question

I see different posts where people are doing, one or the other of, the following:
Lua Code:
  1. LibStub:GetLibrary("LibAddonMenu-2.0")
  2. LibStub("LibAddonMenu-2.0")

What is the difference, if any?
  Reply With Quote
08/23/14, 01:55 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by circonian View Post
I see different posts where people are doing, one or the other of, the following:
Lua Code:
  1. LibStub:GetLibrary("LibAddonMenu-2.0")
  2. LibStub("LibAddonMenu-2.0")

What is the difference, if any?
There is no difference. Direct call of LibStub table calls LibStub:GetLibrary method.

See this line in the library code:
Lua Code:
  1. setmetatable(LibStub, { __call = LibStub.GetLibrary })

A bit more about metatables:
http://lua-users.org/wiki/MetatableEvents
http://nova-fusion.com/2011/06/30/lu...bles-tutorial/
  Reply With Quote
08/23/14, 01:56 PM   #3
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 89
none

LibStub("LibAddonMenu-2.0") will result internally to a call to LibStub:GetLibrary

I prefer to be verbose in such things when coding so i just use LibStub:GetLibrary
  Reply With Quote
08/23/14, 01:58 PM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Ah, that was my guess, but I wasn't sure. Thanks.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » LibStub Question


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