WoWInterface - View Single Post - How to show XML frame with slash command
View Single Post
04-16-21, 08:13 PM   #8
A Pyroguard Emberseer
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,026
Do you have script errors turned on? Errors earlier in your code can block the rest of it from running.
Run /console scriptErrors 1 to enable. (It's also a good idea to /reload afterward to see any errors you missed in the loading process too)

Keep your ToC load order in mind. Files are loaded one at a time in the order listed in your ToC file. If your XML loads first, it can't access the functions defined for your script handlers in your Lua file. If you load Lua first, the frame defined in the XML won't be loaded yet either.

Let's assume you have your Lua file loaded first as this is easier to work with. Here's the code you posted.
Originally Posted by nemvokrobot View Post
Lua Code:
  1. local myframe = TestFrame;
  2. SLASH_SHOWTEST1 = "/showtest"
  3. SlashCmdList["SHOWTEST"] = function(message, editbox)
  4.     myframe:Show();
  5. end
As I mentioned earlier, when the Lua file is loaded first, TestFrame doesn't exist yet, so myframe gets assigned nil. When you run your slash command, it should throw an "attempt to index nil" error if you had scriptErrors enabled. The best way to fix this is to get rid of the myframe local.
Lua Code:
  1. SLASH_SHOWTEST1 = "/showtest"
  2. SlashCmdList["SHOWTEST"] = function(message, editbox)
  3.     TestFrame:Show();
  4. end
This causes the global TestFrame to resolve when the slash command is run and isn't affected by your ToC load order.
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 04-16-21 at 08:36 PM.
  Reply With Quote