### Register a New Library with LibStub Source: https://www.wowace.com/projects/libstub Use NewLibrary to register a new library. If the library is already loaded and no upgrade is necessary, it returns nil. This example shows basic registration and setup. ```lua local lib = LibStub:NewLibrary("MyLibrary-1.0", 1) if not lib then return -- already loaded and no upgrade necessary end lib.somearray = lib.somearray or {} if not lib.frame then lib.frame=CreateFrame("Frame") end function lib:SomeFunction() -- do stuff here end function lib:SomeOtherFunction() -- do other stuff here end local function OnUpdate() -- timing stuff here end lib.frame:SetScript("OnUpdate", OnUpdate); ``` -------------------------------- ### Checkout LibStub Source Code with SVN Source: https://www.wowace.com/projects/libstub/source Use this command to get a copy of the LibStub project's source code from the repository. ```bash svn checkout https://repos.wowace.com/wow/libstub/trunk libstub ``` -------------------------------- ### Register Library with Revision Tag Source: https://www.wowace.com/projects/libstub Register a library using a revision control system tag for the minor version. Be cautious when moving repositories, as revision numbers change. A fallback is provided for handling such cases. ```lua local lib = LibStub:NewLibrary("MyLibrary-1.0", "$Revision: 12345$") ``` ```lua local lib = LibStub:NewLibrary("MyLibrary-1.0", 12345+tonumber(strmatch("%d+","$Revision: 2$")) ) ```