View Single Post
04-14-12, 03:37 AM   #12
deemaxm
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 19
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
  Reply With Quote