1. #1

    Why won't my Static Popup Dialog box addon work?

    Hey guys. I want to know how to get it so that the second dialog box (ChatBox2) will show up after I have reloaded the UI using the first Dialog Box (ChatBox). When I press the Reload button I created, the "StaticPopup_Show("ChatBox2")" does not execute. However I only want the 2nd dialog box to show after pressing this button which is why I need the "StaticPopup_Hide("ChatBox2")" at the end. Can anyone help me out? I 've seen this sort of thing being used before so I'm pretty sure it should be possible to do.

    local Reload = (...)
    StaticPopupDialogs["ChatBox"] = {
    timeout=0,
    text="Only an Example: Press Reload button to get to the next dialog box",
    button1="Reload",
    button2="Cancel",
    OnAccept=function()
    StaticPopup_Hide("ChatBox")
    ReloadUI();
    StaticPopup_Show("ChatBox2")
    end,
    OnCancel=function()
    StaticPopup_Hide("ChatBox")
    end,
    }

    StaticPopupDialogs["ChatBox2"] = {
    timeout=0,
    text="Only an Example: Something something something",
    button1="Okay",
    OnAccept=function()
    StaticPopup_Hide("ChatBox2")
    end,
    }

    StaticPopup_Hide("ChatBox")
    StaticPopup_Hide("ChatBox2")

    ---------- Post added 2012-08-16 at 10:43 PM ----------

    Also while I'm asking, does anyone know why this does not work?:
    nibChatTabs.db.profile:SetProfile("Profile2")

    The addon nibChatTabs has its own gui which I think is causing the profile switching to not work. I got the db from the first 3 lines at the top of the addons lua core file:

    local nibChatTabs = LibStub("AceAddon-3.0"):NewAddon("nibChatTabs", "AceConsole-3.0", "AceEvent-3.0")
    local LSM = LibStub("LibSharedMedia-3.0")
    local db

    Thank you!
    Last edited by MayronWoW; 2012-08-16 at 09:43 PM.

  2. #2
    when linking frames to each other you need to work backwards, so the last frame that appears (in your case StaticPopupDialogs["ChatBox2"]) needs to be the first to be coded

    also im not sure if you can get the 2nd static popup to appear directly after a reload, but i could be wrong

  3. #3
    Deleted
    ReloadUI kills the entire current Lua state and loads a new one. The current stack is never processed.

    You'd have to set a SavedVariable before reload, then look for your addon's ADDON_LOADED and see if the var is set - if it is, you show the second dialog box and unset the var.

    ---------- Post added 2012-08-17 at 08:17 PM ----------

    Quote Originally Posted by SpaceDuck View Post
    when linking frames to each other you need to work backwards, so the last frame that appears (in your case StaticPopupDialogs["ChatBox2"]) needs to be the first to be coded

    also im not sure if you can get the 2nd static popup to appear directly after a reload, but i could be wrong
    Not really, in this case. Table lookups work by reference + indexing (as opposed to locals, where the name is merely an alias for an index on the stack and doesn't even show in the precompiled code).

    For example, this will work:
    Code:
    local a = {}
    local function b() print(a["c"]) end
    a["c"] = 42
    print(a) -- 42
    This is because the preprocessor knows that "a" refers to a local (identified by stack index) when it processes the function body. The table lookup 'a["c"]' is done at runtime (a GETTABLE in the processed file) - only the table itself is fixed by the "a" local that is embedded in the function body.

    As opposed to this, which will not work:
    Code:
    local function b() print(a) end
    local a = 42
    print(a) -- nil
    This is because the preprocessor does not know what "a" refers to when it builds the "b" function body. It thus assumes that "a" is a global (which it isn't).

Posting Permissions

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