1. #1
    Mechagnome MayronEU's Avatar
    Join Date
    Mar 2012

    Issue with getglobal / _G[] - Not working correctly

    Hi am I doing something wrong?

    When I use:
    I get the correct result returned and printed.

    However when I use:
    I get nil

    I have tested it using the line above but I actually need it like this:

    local global = _G["MayronUI.db.global.modkey." .. frame]

    I have used _G[] before like this and has never failed. MayronUI.db.global is a global table. What am I doing wrong?

    Thank you for reading!

  2. #2
    It would be _G.MayronUI.db.global.modkey.expand_retract

    If you really want to wrap it in quotes, it would be _G["MayronUI"]["db"]["global"]["modkey"]["expand_retract"] or you can also do _G["MayronUI"]["db"]["global"].modkey.expand_retract etc.

    There's not much point in doing so unless you're wanting to e.g. use a local variable as the address to the table, like:

    local location = "expand_retract"
    Then you could access _G.MayronUI.db.global.modkey[location]

    So assuming "frame" is actually a name, not the frame/table address location, you'd want:
    local global = _G.MayronUI.db.global.modkey[frame]
    Last edited by funkydude; 2013-12-24 at 03:02 PM.
    Author of BadBoy, BasicChatMods, BigWigs, oRA3, SexyMap, [...]

    DBM: 21.2 CPU/sec
    BW: 3.7 CPU/sec

  3. #3
    Yeah the issue is that the entire string is the key; you can't put in a string that's supposed to go 5 levels deep into the table and expect the Lua to pull out the key at each level.

  4. #4
    Mechagnome MayronEU's Avatar
    Join Date
    Mar 2012
    Thanks guys! Works perfectly
    Just me being dumb then hehe
    Appreciate the explanation as well!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts