WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   nibProfileLoader (https://www.wowinterface.com/forums/showthread.php?t=43213)

Orko 04-07-12 06:50 PM

nibProfileLoader
 
Im currently trying to set up a UI that has two totally different layouts for a tank and a healer. What I have used so far is Reflux and nibprofileloader. What I want to see if I can do is rework nibprofileloader to instead of asking this.....


New Character detected. Would you like to load profile xxxx?
--- Yes --- --- No ----


I want it two have different answers like this..

Thanks for using xxxx UI. Please select a UI layout from options below.
---Tank --- --- Healer ---


Basically what nib does is if you press YES it will load a predetermined profile and if you press no it cancels out and closes the window. What I need it to do is where the Yes button is will load a tank profile and where No button is load Heal profile. Hope someone understands this and can help!!

Phanx 04-07-12 08:52 PM

I've never heard of nibProfileLoader, but you could probably write something like that very easily for Reflux. You would need to read a list of Reflux profiles, and add a button for each one.

If you want more specific help, you will need to post your code and describe what you want to change, and what you have already tried.

Orko 04-07-12 10:10 PM

Here is the code from the addon I am using. I want an option to load two different profiles instead of just one. Right now the choices are load one profile or exit with the No button. Just a Yes or No button is currently there and I want like I descirbed in original post..

Lua Code:
  1. local frame = CreateFrame("FRAME");
  2. frame:RegisterEvent("VARIABLES_LOADED");
  3.  
  4. -- BEGIN USER OPTIONS --
  5. -- InterfaceName = Name to describe your UI
  6. -- ProfileName = Addon profile name to use with /reflux switch
  7. local InterfaceName  = "MyInterface"
  8. local ProfileName = "MyProfile"
  9.  
  10. local UseClassProfiles = false  -- Use specific profile names for different classes
  11. local ClassProfiles = {         -- Change profile names to suit
  12.     ["DEATHKNIGHT"] = "MyProfile",
  13.     ["DRUID"] = "MyProfile",
  14.     ["HUNTER"] = "MyProfile",
  15.     ["MAGE"] = "MyProfile",
  16.     ["PALADIN"] = "MyProfile",
  17.     ["PRIEST"] = "MyProfile",
  18.     ["ROGUE"] = "MyProfile",
  19.     ["SHAMAN"] = "MyProfile",
  20.     ["WARLOCK"] = "MyProfile",
  21.     ["WARRIOR"] = "MyProfile",
  22. }
  23. -- END USER OPTIONS --
  24.  
  25. local LocalizedMessages = {
  26.     ["enUS"] = {
  27.         [1] = "New character detected! Do you wish to load the settings for %s?",
  28.         [2] = "Yes",
  29.         [3] = "No",
  30.     },
  31.     ["deDE"] = {
  32.         [1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
  33.         [2] = "Ja",
  34.         [3] = "Nein",
  35.     },
  36. }
  37.  
  38.  
  39. local CID, CE, HasAdded = "", false, false
  40.  
  41. local function AddChar()
  42.   if (CID ~= "") and not HasAdded then
  43.     tinsert(nibPLNames, CID)
  44.     HasAdded = true
  45.   end
  46. end
  47.  
  48. local function CharAnswered(ans)
  49.   AddChar()
  50.   if ans then
  51.     local _, class = UnitClass("player")
  52.     local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
  53.     local RefluxArg = string.format("%s %s", "switch", NewProfile)
  54.     SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  55.   end
  56. end
  57.  
  58. local function AskNewChar()
  59.   local Locale = GetLocale() or "enUS"
  60.   local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
  61.   StaticPopupDialogs["PUDASKNEWCHAR"] = {
  62.     text = MsgTexts[1],
  63.     button1 = MsgTexts[2],
  64.     button2 = MsgTexts[3],
  65.     OnAccept = function()
  66.       CharAnswered(true)
  67.     end,
  68.     OnCancel = function()
  69.       CharAnswered(false)
  70.     end,
  71.     timeout = 0,
  72.     whileDead = true,
  73.     hideOnEscape = false,
  74.     notClosableByLogout = true,
  75.   }
  76.   StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
  77. end
  78.  
  79. local function CheckNewChar()
  80.   CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
  81.   CE = false
  82.   if (nibPLNames == nil) then nibPLNames = { }; end
  83.   for i,v in pairs(nibPLNames) do
  84.     if (v == CID) then CE = true; end
  85.   end
  86.   if not CE then AskNewChar(); end
  87. end
  88.  
  89. local function eventHandler(self, event, ...)
  90.   if (event == "VARIABLES_LOADED") then
  91.     CheckNewChar()
  92.   end
  93. end
  94. frame:SetScript("OnEvent", eventHandler);

Lordyfrb 04-08-12 05:58 AM

This should work for you, not tested as I dont use reflux or nibProfileLoader.
Lua Code:
  1. local frame = CreateFrame("FRAME");
  2.     frame:RegisterEvent("VARIABLES_LOADED");
  3.      
  4.     -- BEGIN USER OPTIONS --
  5.     -- InterfaceName = Name to describe your UI
  6.     -- ProfileName = Addon profile name to use with /reflux switch
  7.     local InterfaceName  = "MyInterface"
  8.     local TankName = "MyTankProfile"
  9.     local HealName = "MyHealProfile"
  10.      
  11.     local UseClassProfiles = false  -- Use specific profile names for different classes
  12.     local ClassProfiles = {         -- Change profile names to suit
  13.         ["DEATHKNIGHT"] = "MyProfile",
  14.         ["DRUID"] = "MyProfile",
  15.         ["HUNTER"] = "MyProfile",
  16.         ["MAGE"] = "MyProfile",
  17.         ["PALADIN"] = "MyProfile",
  18.         ["PRIEST"] = "MyProfile",
  19.         ["ROGUE"] = "MyProfile",
  20.         ["SHAMAN"] = "MyProfile",
  21.         ["WARLOCK"] = "MyProfile",
  22.         ["WARRIOR"] = "MyProfile",
  23.     }
  24.     -- END USER OPTIONS --
  25.      
  26.     local LocalizedMessages = {
  27.         ["enUS"] = {
  28.             [1] = "Thanks for using xxxx UI. Please select a UI layout from options below.",
  29.             [2] = "Tank",
  30.             [3] = "Heal",
  31.         },
  32.         ["deDE"] = {
  33.             [1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
  34.             [2] = "Ja",
  35.             [3] = "Nein",
  36.         },
  37.     }
  38.      
  39.      
  40.     local CID, CE, HasAdded = "", false, false
  41.      
  42.     local function AddChar()
  43.       if (CID ~= "") and not HasAdded then
  44.         tinsert(nibPLNames, CID)
  45.         HasAdded = true
  46.       end
  47.     end
  48.      
  49.     local function CharAnswered(ans)
  50.       AddChar()
  51.       if ans == "Tank" then
  52.         local _, class = UnitClass("player")
  53.         local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
  54.         local RefluxArg = string.format("%s %s", "switch", TankProfile)
  55.         SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  56.       elseif ans == "Heal" then
  57.         local _, class = UnitClass("player")
  58.         local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
  59.         local RefluxArg = string.format("%s %s", "switch", HealProfile)
  60.         SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  61.       end
  62.     end
  63.      
  64.     local function AskNewChar()
  65.       local Locale = GetLocale() or "enUS"
  66.       local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
  67.       StaticPopupDialogs["PUDASKNEWCHAR"] = {
  68.         text = MsgTexts[1],
  69.         button1 = MsgTexts[2],
  70.         button2 = MsgTexts[3],
  71.         OnAccept = function()
  72.           CharAnswered(Tank)
  73.         end,
  74.         OnCancel = function()
  75.           CharAnswered(Heal)
  76.         end,
  77.         timeout = 0,
  78.         whileDead = true,
  79.         hideOnEscape = false,
  80.         notClosableByLogout = true,
  81.       }
  82.       StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
  83.     end
  84.      
  85.     local function CheckNewChar()
  86.       CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
  87.       CE = false
  88.       if (nibPLNames == nil) then nibPLNames = { }; end
  89.       for i,v in pairs(nibPLNames) do
  90.         if (v == CID) then CE = true; end
  91.       end
  92.       if not CE then AskNewChar(); end
  93.     end
  94.      
  95.     local function eventHandler(self, event, ...)
  96.       if (event == "VARIABLES_LOADED") then
  97.         CheckNewChar()
  98.       end
  99.     end
  100.     frame:SetScript("OnEvent", eventHandler);

Orko 04-08-12 03:44 PM

Oh sweet I will try this ASAP. The problem I have is I dont know how to code and did not know how the buttons worked. Couldnt figure that part out. Ill see how this goes and will let you know.

Orko 04-08-12 03:57 PM

Ok I tried this modification and it does not do anything. After selecting Tank or Heal the window cancels and nothing happens. No profile switch or reloadui. Trying to see what I can find out. Im not getting any errors or anything. Just not doing what its intended to do.

Nibelheim 04-08-12 04:29 PM

There were some quotes missing around Tank and Heal, but rest should be good.

Lua Code:
  1. local frame = CreateFrame("FRAME");
  2. frame:RegisterEvent("VARIABLES_LOADED");
  3.      
  4. -- BEGIN USER OPTIONS --
  5. -- InterfaceName = Name to describe your UI
  6. -- ProfileName = Addon profile name to use with /reflux switch
  7. local InterfaceName  = "MyInterface"
  8. local TankName = "MyTankProfile"
  9. local HealName = "MyHealProfile"
  10.      
  11. local UseClassProfiles = false  -- Use specific profile names for different classes
  12. local ClassProfiles = {         -- Change profile names to suit
  13.     ["DEATHKNIGHT"] = "MyProfile",
  14.     ["DRUID"] = "MyProfile",
  15.     ["HUNTER"] = "MyProfile",
  16.     ["MAGE"] = "MyProfile",
  17.     ["PALADIN"] = "MyProfile",
  18.     ["PRIEST"] = "MyProfile",
  19.     ["ROGUE"] = "MyProfile",
  20.     ["SHAMAN"] = "MyProfile",
  21.     ["WARLOCK"] = "MyProfile",
  22.     ["WARRIOR"] = "MyProfile",
  23. }
  24. -- END USER OPTIONS --
  25.  
  26. local LocalizedMessages = {
  27.     ["enUS"] = {
  28.         [1] = "Thanks for using xxxx UI. Please select a UI layout from options below.",
  29.         [2] = "Tank",
  30.         [3] = "Heal",
  31.     },
  32.     ["deDE"] = {
  33.         [1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
  34.         [2] = "Ja",
  35.         [3] = "Nein",
  36.     },
  37. }
  38.  
  39.  
  40. local CID, CE, HasAdded = "", false, false
  41.  
  42. local function AddChar()
  43.   if (CID ~= "") and not HasAdded then
  44.     tinsert(nibPLNames, CID)
  45.     HasAdded = true
  46.   end
  47. end
  48.  
  49. local function CharAnswered(ans)
  50.   AddChar()
  51.   if ans == "Tank" then
  52.     local _, class = UnitClass("player")
  53.     local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
  54.     local RefluxArg = string.format("%s %s", "switch", TankProfile)
  55.     SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  56.   elseif ans == "Heal" then
  57.     local _, class = UnitClass("player")
  58.     local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
  59.     local RefluxArg = string.format("%s %s", "switch", HealProfile)
  60.     SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  61.   end
  62. end
  63.  
  64. local function AskNewChar()
  65.   local Locale = GetLocale() or "enUS"
  66.   local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
  67.   StaticPopupDialogs["PUDASKNEWCHAR"] = {
  68.     text = MsgTexts[1],
  69.     button1 = MsgTexts[2],
  70.     button2 = MsgTexts[3],
  71.     OnAccept = function()
  72.       CharAnswered("Tank")
  73.     end,
  74.     OnCancel = function()
  75.       CharAnswered("Heal")
  76.     end,
  77.     timeout = 0,
  78.     whileDead = true,
  79.     hideOnEscape = false,
  80.     notClosableByLogout = true,
  81.   }
  82.   StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
  83. end
  84.  
  85. local function CheckNewChar()
  86.   CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
  87.   CE = false
  88.   if (nibPLNames == nil) then nibPLNames = { }; end
  89.   for i,v in pairs(nibPLNames) do
  90.     if (v == CID) then CE = true; end
  91.   end
  92.   if not CE then AskNewChar(); end
  93. end
  94.  
  95. local function eventHandler(self, event, ...)
  96.   if (event == "VARIABLES_LOADED") then
  97.     CheckNewChar()
  98.   end
  99. end
  100. frame:SetScript("OnEvent", eventHandler);

Orko 04-08-12 04:32 PM

Ah that was it and now its working. I still do not know how the addon knows what button is hit but anyhow its working. I really wanna learn this stuff but I had no idea where to begin.

Thanks again all. Now its working with 2 profiles.

Orko 04-08-12 04:35 PM

Also I changed this line....

local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName

to this...

local NewProfile = UseClassProfiles and ClassProfiles[class] or TankName

and also for healer one...

local NewProfile = UseClassProfiles and ClassProfiles[class] or HealName

Not sure if that was needed but its still working with no errors.

Nibelheim 04-08-12 04:36 PM

All done through WoW's PopupDialog API.

Lua Code:
  1. -- Define a new Pop Up message
  2. StaticPopupDialogs["PUDASKNEWCHAR"] = {
  3.     -- Message to display
  4.     text = MsgTexts[1],
  5.  
  6.     -- Text to show on first button
  7.     button1 = MsgTexts[2],
  8.  
  9.     -- Text to show on second button
  10.     button2 = MsgTexts[3],
  11.  
  12.     -- Function to call when first button is pressed
  13.     OnAccept = function()
  14.         -- Call CharAnswered with "Tank" argument
  15.         CharAnswered("Tank")
  16.     end,
  17.  
  18.     -- Function to call when second button is pressed
  19.     OnCancel = function()
  20.         -- Call CharAnswered with "Heal" argument
  21.         CharAnswered("Heal")
  22.     end,
  23.  
  24.     -- Pop Up message stays open until user action
  25.     timeout = 0,
  26.  
  27.     -- Pop Up message is shown even if the player is dead
  28.     whileDead = true,
  29.  
  30.     -- Hitting Esc won't close the Pop Up message
  31.     hideOnEscape = false,
  32.  
  33.     -- Logging out won't send the signal to hit the second button (OnCancel), thereby making the Pop Up message show next time they log in if they didn't click any buttons
  34.     notClosableByLogout = true,
  35. }
  36.  
  37. -- Show the Pop Up message
  38. StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);

Quote:

Not sure if that was needed but its still working with no errors.
Ahh yes, that was needed. Good catch :)

Orko 04-08-12 05:21 PM

Thank you very much for adding those comments. Now I got a better understanding how it works. Heck yeah! I learned something today :)

deemaxm 04-14-12 03:37 AM

Code:

local frame = CreateFrame("FRAME");
frame:RegisterEvent("VARIABLES_LOADED");
   
-- BEGIN USER OPTIONS --
-- InterfaceName = Name to describe your UI
-- ProfileName = Addon profile name to use with /reflux switch
local InterfaceName  = "Deeui4"
local TankName = "DeeUi-DPS"
local HealName = "DeeUi-Heal"
   
local UseClassProfiles = false  -- Use specific profile names for different classes
local ClassProfiles = {        -- Change profile names to suit
    ["DEATHKNIGHT"] = "MyProfile",
    ["DRUID"] = "MyProfile",
    ["HUNTER"] = "MyProfile",
    ["MAGE"] = "MyProfile",
    ["PALADIN"] = "MyProfile",
    ["PRIEST"] = "MyProfile",
    ["ROGUE"] = "MyProfile",
    ["SHAMAN"] = "MyProfile",
    ["WARLOCK"] = "MyProfile",
    ["WARRIOR"] = "MyProfile",
}
-- END USER OPTIONS --
 
local LocalizedMessages = {
    ["enUS"] = {
        [1] = "Thanks for using DeeUi4. Choose your destiny.",
        [2] = "Tank/DPS",
        [3] = "Heal",
    },
    ["deDE"] = {
        [1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
        [2] = "Ja",
        [3] = "Nein",
    },
}
 
 
local CID, CE, HasAdded = "", false, false
 
local function AddChar()
  if (CID ~= "") and not HasAdded then
    tinsert(nibPLNames, CID)
    HasAdded = true
  end
end
 
local function CharAnswered(ans)
  AddChar()
  if ans == "Tank" then
    local _, class = UnitClass("player")
    local NewProfile = UseClassProfiles and ClassProfiles[class] or TankName
    local RefluxArg = string.format("%s %s", "switch", DeeUi-DPS)
    SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  elseif ans == "Heal" then
    local _, class = UnitClass("player")
    local NewProfile = UseClassProfiles and ClassProfiles[class] or HealName
    local RefluxArg = string.format("%s %s", "switch", DeeUi-Heal)
    SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  end
end
 
local function AskNewChar()
  local Locale = GetLocale() or "enUS"
  local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
  -- Define a new Pop Up message
StaticPopupDialogs["PUDASKNEWCHAR"] = {
    -- Message to display
    text = Thank you for using DeeUi4[1],
 
    -- Text to show on first button
    button1 = Tank/DPS[2],
 
    -- Text to show on second button
    button2 = Heal[3],
 
    -- Function to call when first button is pressed
    OnAccept = function()
        -- Call CharAnswered with "Tank" argument
        CharAnswered("Tank/DPS")
    end,
 
    -- Function to call when second button is pressed
    OnCancel = function()
        -- Call CharAnswered with "Heal" argument
        CharAnswered("Heal")
    end,
 
    -- Pop Up message stays open until user action
    timeout = 0,
 
    -- Pop Up message is shown even if the player is dead
    whileDead = true,
 
    -- Hitting Esc won't close the Pop Up message
    hideOnEscape = false,
 
    -- Logging out won't send the signal to hit the second button (OnCancel), thereby making the Pop Up message show next time they log in if they didn't click any buttons
    notClosableByLogout = true,
}
 
-- Show the Pop Up message
StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
end
 
local function CheckNewChar()
  CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
  CE = false
  if (nibPLNames == nil) then nibPLNames = { }; end
  for i,v in pairs(nibPLNames) do
    if (v == CID) then CE = true; end
  end
  if not CE then AskNewChar(); end
end
 
local function eventHandler(self, event, ...)
  if (event == "VARIABLES_LOADED") then
    CheckNewChar()
  end
end
frame:SetScript("OnEvent", eventHandler);

This is how i tryed to adapt modifications above but i still get an error that says:
Code:

Interface\AddOns\nibProfileLoader\nibProfileLoader.lua:70: '}' expected (to close '{' at line 68) near 'you'
Time: 04/14/12 12:34:02
Count: 1
Stack:
Locals

Anyone can explain where i did ****up the code pls??
<-Lua Nub/Greenhorn

Rilgamon 04-14-12 05:07 AM

Line 70 is

Lua Code:
  1. text = Thank you for using DeeUi4[1],

Strings should be put in '' or "" ... and no clue what your [#] is meant to be :)

deemaxm 04-14-12 06:28 AM

changed what you said so now it is like this
Code:

local frame = CreateFrame("FRAME");
frame:RegisterEvent("VARIABLES_LOADED");
   
-- BEGIN USER OPTIONS --
-- InterfaceName = Name to describe your UI
-- ProfileName = Addon profile name to use with /reflux switch
local InterfaceName  = "Deeui4"
local TankName = "DeeUi-DPS"
local HealName = "DeeUi-Heal"
   
local UseClassProfiles = false  -- Use specific profile names for different classes
local ClassProfiles = {        -- Change profile names to suit
    ["DEATHKNIGHT"] = "MyProfile",
    ["DRUID"] = "MyProfile",
    ["HUNTER"] = "MyProfile",
    ["MAGE"] = "MyProfile",
    ["PALADIN"] = "MyProfile",
    ["PRIEST"] = "MyProfile",
    ["ROGUE"] = "MyProfile",
    ["SHAMAN"] = "MyProfile",
    ["WARLOCK"] = "MyProfile",
    ["WARRIOR"] = "MyProfile",
}
-- END USER OPTIONS --
 
local LocalizedMessages = {
    ["enUS"] = {
        [1] = "Thanks for using DeeUi4. Choose your destiny.",
        [2] = "Tank/DPS",
        [3] = "Heal",
    },
    ["deDE"] = {
        [1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
        [2] = "Ja",
        [3] = "Nein",
    },
}
 
 
local CID, CE, HasAdded = "", false, false
 
local function AddChar()
  if (CID ~= "") and not HasAdded then
    tinsert(nibPLNames, CID)
    HasAdded = true
  end
end
 
local function CharAnswered(ans)
  AddChar()
  if ans == "Tank" then
    local _, class = UnitClass("player")
    local NewProfile = UseClassProfiles and ClassProfiles[class] or TankName
    local RefluxArg = string.format("%s %s", "switch", DeeUi-DPS)
    SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  elseif ans == "Heal" then
    local _, class = UnitClass("player")
    local NewProfile = UseClassProfiles and ClassProfiles[class] or HealName
    local RefluxArg = string.format("%s %s", "switch", DeeUi-Heal)
    SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  end
end
 
local function AskNewChar()
  local Locale = GetLocale() or "enUS"
  local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
  -- Define a new Pop Up message
StaticPopupDialogs["PUDASKNEWCHAR"] = {
    -- Message to display
    text = "Thank you for using DeeUi4"[1];
 
    -- Text to show on first button
    button1 = "Tank/DPS"[2];
 
    -- Text to show on second button
    button2 = "Heal"[3];
 
    -- Function to call when first button is pressed
    OnAccept = function()
        -- Call CharAnswered with "Tank" argument
        CharAnswered("Tank/DPS");
    end
 
    -- Function to call when second button is pressed
    OnCancel = function()
        -- Call CharAnswered with "Heal" argument
        CharAnswered("Heal");
    end
 
    -- Pop Up message stays open until user action
    timeout = 0;
 
    -- Pop Up message is shown even if the player is dead
    whileDead = true,
 
    -- Hitting Esc won't close the Pop Up message
    hideOnEscape = false;
 
    -- Logging out won't send the signal to hit the second button (OnCancel), thereby making the Pop Up message show next time they log in if they didn't click any buttons
    notClosableByLogout = true
};
 
-- Show the Pop Up message
StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
end
 
local function CheckNewChar()
  CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
  CE = false
  if (nibPLNames == nil) then nibPLNames = { }; end
  for i,v in pairs(nibPLNames) do
    if (v == CID) then CE = true; end
  end
  if not CE then AskNewChar(); end
end
 
local function eventHandler(self, event, ...)
  if (event == "VARIABLES_LOADED") then
    CheckNewChar()
  end
end
frame:SetScript("OnEvent", eventHandler);

and lua error says:
Code:

Message: Interface\AddOns\nibProfileLoader\nibProfileLoader.lua:70: '}' expected (to close '{' at line 68) near '['
Time: 04/14/12 15:24:37
Count: 1
Stack:
Locals:


Rilgamon 04-14-12 10:31 AM

skip [1][2][3] ... those brackets make no sense at all :)

Nibelheim 04-14-12 12:54 PM

Lua Code:
  1. local frame = CreateFrame("FRAME");
  2. frame:RegisterEvent("VARIABLES_LOADED");
  3.      
  4. -- BEGIN USER OPTIONS --
  5. -- InterfaceName = Name to describe your UI
  6. -- ProfileName = Addon profile name to use with /reflux switch
  7. local InterfaceName  = "Deeui4"
  8. local TankName = "DeeUi-DPS"
  9. local HealName = "DeeUi-Heal"
  10.      
  11. local UseClassProfiles = false  -- Use specific profile names for different classes
  12. local ClassProfiles = {         -- Change profile names to suit
  13.     ["DEATHKNIGHT"] = "MyProfile",
  14.     ["DRUID"] = "MyProfile",
  15.     ["HUNTER"] = "MyProfile",
  16.     ["MAGE"] = "MyProfile",
  17.     ["PALADIN"] = "MyProfile",
  18.     ["PRIEST"] = "MyProfile",
  19.     ["ROGUE"] = "MyProfile",
  20.     ["SHAMAN"] = "MyProfile",
  21.     ["WARLOCK"] = "MyProfile",
  22.     ["WARRIOR"] = "MyProfile",
  23. }
  24. -- END USER OPTIONS --
  25.  
  26. local LocalizedMessages = {
  27.     ["enUS"] = {
  28.         [1] = "Thanks for using DeeUi4. Choose your destiny.",
  29.         [2] = "Tank/DPS",
  30.         [3] = "Heal",
  31.     },
  32.     ["deDE"] = {
  33.         [1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
  34.         [2] = "Tank/DPS",
  35.         [3] = "Heal",
  36.     },
  37. }
  38.  
  39.  
  40. local CID, CE, HasAdded = "", false, false
  41.  
  42. local function AddChar()
  43.   if (CID ~= "") and not HasAdded then
  44.     tinsert(nibPLNames, CID)
  45.     HasAdded = true
  46.   end
  47. end
  48.  
  49. local function CharAnswered(ans)
  50.   AddChar()
  51.   if ans == "Tank" then
  52.     local _, class = UnitClass("player")
  53.     local NewProfile = UseClassProfiles and ClassProfiles[class] or TankName
  54.     local RefluxArg = string.format("%s %s", "switch", DeeUi-DPS)
  55.     SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  56.   elseif ans == "Heal" then
  57.     local _, class = UnitClass("player")
  58.     local NewProfile = UseClassProfiles and ClassProfiles[class] or HealName
  59.     local RefluxArg = string.format("%s %s", "switch", DeeUi-Heal)
  60.     SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  61.   end
  62. end
  63.  
  64. local function AskNewChar()
  65.   local Locale = GetLocale() or "enUS"
  66.   local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
  67.   -- Define a new Pop Up message
  68.   StaticPopupDialogs["PUDASKNEWCHAR"] = {
  69.     -- Message to display
  70.     text = MsgTexts[1];
  71.  
  72.     -- Text to show on first button
  73.     button1 = MsgTexts[2];
  74.  
  75.     -- Text to show on second button
  76.     button2 = MsgTexts[3];
  77.  
  78.     -- Function to call when first button is pressed
  79.     OnAccept = function()
  80.         -- Call CharAnswered with "Tank" argument
  81.         CharAnswered("Tank");
  82.     end
  83.  
  84.     -- Function to call when second button is pressed
  85.     OnCancel = function()
  86.         -- Call CharAnswered with "Heal" argument
  87.         CharAnswered("Heal");
  88.     end
  89.  
  90.     -- Pop Up message stays open until user action
  91.     timeout = 0;
  92.  
  93.     -- Pop Up message is shown even if the player is dead
  94.     whileDead = true,
  95.  
  96.     -- Hitting Esc won't close the Pop Up message
  97.     hideOnEscape = false;
  98.  
  99.     -- Logging out won't send the signal to hit the second button (OnCancel), thereby making the Pop Up message show next time they log in if they didn't click any buttons
  100.     notClosableByLogout = true
  101.   };
  102.  
  103.   -- Show the Pop Up message
  104.   StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
  105. end
  106.  
  107. local function CheckNewChar()
  108.   CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
  109.   CE = false
  110.   if (nibPLNames == nil) then nibPLNames = { }; end
  111.   for i,v in pairs(nibPLNames) do
  112.     if (v == CID) then CE = true; end
  113.   end
  114.   if not CE then AskNewChar(); end
  115. end
  116.  
  117. local function eventHandler(self, event, ...)
  118.   if (event == "VARIABLES_LOADED") then
  119.     CheckNewChar()
  120.   end
  121. end
  122. frame:SetScript("OnEvent", eventHandler)

deemaxm 04-14-12 04:43 PM

cant get it pasted the code from nib into NibProfileLoader.lua and i still get this error :
Code:

Interface\AddOns\nibProfileLoader\nibProfileLoader.lua:85: '}' expected (to close '{' at line 68) near 'OnCancel'
Time: 04/15/12 01:41:12
Count: 1
Stack:
Locals:

any ideas whats wrong?:(

Orko 04-14-12 06:45 PM

The one I have works just fine. I do see something different with yours and let me try and explain this since I am a noob at all this coding :)

Line 54:
Lua Code:
  1. local RefluxArg = string.format("%s %s", "switch", DeeUi-DPS)

This is different than mine. Mine reads like this.


Lua Code:
  1. local RefluxArg = string.format("%s %s", "switch", NewProfile)

Now I think the reason your might not be working is this local thing that is making NewProfile like on line 53:

Lua Code:
  1. local NewProfile = UseClassProfiles and ClassProfiles[class] or TankName

So change DeeUi-DPS to NewProfile and see if that works

Nibelheim 04-14-12 07:04 PM

Yeah, I missed that one. If using straight text as a variable, please enclose it in quotes.

Orko 04-15-12 02:10 PM

Any chance we can update your addon nib or can I upload this modified one? I think there were some players asking about this before on these boards. On how to swap between multiple profiles.


All times are GMT -6. The time now is 02:02 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI