WoWInterface - View Single Post - Static PopUp text help
View Single Post
03-13-15, 05:00 AM   #5
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The problem has nothing to do with concatenation, even though you're doing that wrong in your example. The problem is that a static popup is only defined once, but the OP wants the text it displays to changable. Fortunately, there are several simple solutions available.

#1 - Your text can include up to 2 formatting tokens, and you can pass up to 2 values to StaticPopup_Show:

StaticPopupDialogs["WRONG_SPEC_WARNING"] = {
	text = "Your active role: %s|nYour assigned LFG role: %s",
	-- etc.

StaticPopup_Show("WRONG_SPEC_WARNING", roleReturnValueHere, specReturnValueHere)
#2 - Just change the text before you show the dialog:
StaticPopupDialogs["WRONG_SPEC_WARNING"] = {
	text = "Placeholder text",
	-- etc.

StaticPopupDialogs["WRONG_SPEC_WARNING"].text = "Your active role: " .. roleReturnValueHere .. "|nYour assigned LFG role: " .. specReturnValueHere
The first method is the "official" one, and is simpler, but you'd need to use the second one if you have more than 2 variables, or want to change the whole text, though you could work around that by just setting the text to "%s" and then passing in the entire text you wanted as the second argument to StaticPopup_Show.

Also make sure you have some kind of error display enabled. If your code is "not working" or "nothing happens" there's almost certainly a Lua error telling you exactly what's wrong on which line of code.
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Donít message me about addon bugs or programming questions.
  Reply With Quote