• 0

    posted a message on LibShieldLeft
    All signs point to no.
    Posted in: Libraries
  • 0

    posted a message on Confused about global and local vars
    Quote from airscape
    If I create a global table and then a local variable to store the table in, is everything created from that local var considered local?
    TestAddon = {}
    local mod = TestAddon
    


    TestAddon is a global. mod is a local. Both of them reference the exact same table in memory, think of variable assignments using a table as the value like a pointer reference.

    Quote from airscape
    and if I make a function like this
    function mod:TestFunction()
    end
    
    it that function global or local?


    It is both. When you use mod you are referencing the local variable instead of the global variable, the reason developers do this is because it is faster to reference a local variable than a global variable. When using this syntax, which is often referred to as 'method notation' you should always access your addon table with the 'self' variable while inside the functions.

    Quote from airscape
    also, if I create a texture like this
    mod.frame = CreateFrame("Frame")
    texture = mod.frame:CreateTexture()
    
    is the texture global or local?


    'texture' is a global. Lua is a Global By Default language, all assignments create a global if the variable name does not exist yet. If the name already exists as a local then that local variable is changed.

    There are some cases in which a local variable is automatically created for you like 'self' when using method notation. Also for loops create local variables for you. Here is an example.

    i = 10			-- global variable 'i' is equal to the number 10.
    local i			-- 'i' is now a local variable but it does not 
    			-- have a value assigned to it yet so it is 'nil'
    			-- the global variable 'i' still exists
    			-- and is still equal to the number 10
    i = 100			-- the local variable 'i' is now equal to the number 100
    for i = 1, 3 do
    			-- now we have created a loop which will use the variable 'i'
                            -- the loop will start at the number 1 and end at the number 3
                            -- and will increase the iterator variable by 1 every pass
      print(i)
      i = i + 10
    end
    print(i)
    print(_G.i)             -- we are going to cheat and use _G to access the global
                            -- variable 'i' while we still have a local variable 'i'
    


    This code would output the following.
    1
    2
    3
    100
    10
    

    Notice that the 'i = i + 10' had absolutely no effect on the loop or the output directly after the loop. This is because a new local variable named 'i' was created for every iteration of the loop.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Blank lua error and broken blizzard UI
    Quote from delphyne
    I'm new to Lua, but by no means new to programming. I've come from a tradition of C, C++, and Java, where globals are severely frowned upon mostly due to multi-threading issues. As such, Java (and its successors like Groovy, Scala, Clojure, etc.) all severely limit your capability to create true globals.

    I suppose if you're limited to such a tight namespace, global by default makes more sense. However, it has the potential to wreak havoc. For example, when I replaced the functions min() and max() with an integer value... um... oops!?

    I've adjusted my expectations appropriately and now I'm stumbling towards my next "gotcha." Many thanks for the help.


    http://lua-users.org/wiki/LocalByDefault

    http://en.wikipedia.org/wiki/Scope_%28programming%29#Static_scoping_.28also_known_as_lexical_scoping.29

    Lua properly implements lexical scoping.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Question on Hooks coming unhooked.
    /dump issecurevariable("HandleModifiedItemClick")
    Posted in: Lua Code Discussion
  • 0

    posted a message on UnitAura Hooking
    No.

    Hooking any API always risks severely tainting the UI because it gets used in secure parts of the UI. Only a limited few are able to safely be hooked and UnitAura is not one of them.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Changes to the LibBabble Libraries - Translators Read!
    LibBabble-Quests-3.0 doesn't exist (ok it does but its dead, and it was always a stupid idea to begin with and should have never been created in the first place). Either disable the addon trying to use it or the module in the addon. The library will not be fixed.
    Posted in: Libraries
  • 0

    posted a message on Question on Hooks coming unhooked.
    Are you using :SecureHook() because the function you are hooking is secure? If it is then whatever addon is breaking your hook must also be breaking all usage of the function. If its not a secure function then you have no reason to be using :SecureHook(), but you'll still have the problem of another addon breaking the hook.
    Posted in: Lua Code Discussion
  • 0

    posted a message on WTB info on the "Edit external repository" feature
    Ah I didn't realize it dumped it into the moderation queue. I don't think it did that last time I talked to anybody about the details of it.
    Posted in: General Chat
  • 0

    posted a message on Per-Addon Forums, where are the options
    You can? I couldn't find anything for them last time I looked.
    Posted in: General Chat
  • 0

    posted a message on WTB info on the "Edit external repository" feature
    AFAIK this feature is also locked down and requires an admin to approve any changes to the external repo URL. It bypasses all the security precommit hooks so usage of it is restricted to only trusted authors with secure svn repos.

    Note that I said admin, not moderator.
    Posted in: General Chat
  • 0

    posted a message on Frame appears outside options dialog . . .
    You can use custom widgets with AceConfigDialog-3.0, just look at how the LSM3 widgets are used.
    Posted in: Ace3
  • 0

    posted a message on Looking for simple bag mod to dissect
    Try Bagnon by Tuller.
    Posted in: AddOn HELP!
  • 0

    posted a message on LibInterface-1.0 (object checking)
    Lua is designed for libraries, just not the way we use libraries since Blizzard disables the "require" keyword.
    Posted in: Ace3
  • 0

    posted a message on Unauthorized Addon Sites - Authors Beware!
    I tipped Kaelten off to that site months ago when some asshat posted on the UI&Macro forums about limited alpha signups for it and I noticed stuff about premium service in their EULA. Luckily the forum mods deleted that crap.
    Posted in: General Chat
  • 0

    posted a message on DeuceCommander replacement or fix?`
    How the hell can you even still be using enough Ace2 addons that DeuceCommander/Niagara is useful? There shouldn't be that many Ace2 addons left that still work.
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.