Thread Tools Display Modes
04-02-16, 06:55 PM   #1
suipsyco
A Deviate Faerie Dragon
Join Date: Apr 2016
Posts: 13
Slash Commands

I've read so many posts and tutorials on this but I can't find the fault in my code... i have

Code:
SlashCmdList["RAIDLOCKREPORT"] = DEFAULT_CHAT_FRAME:AddMessage("Working");
SLASH_RAIDLOCKREPORT1 = "/raidlockreport";
SLASH_RAIDLOCKREPORT2 = "/rlr";
When I run the code I get "Type '/help' for a listing of a few commands."
  Reply With Quote
04-02-16, 07:48 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by suipsyco View Post
I've read so many posts and tutorials on this but I can't find the fault in my code... i have

Code:
SlashCmdList["RAIDLOCKREPORT"] = DEFAULT_CHAT_FRAME:AddMessage("Working");
SLASH_RAIDLOCKREPORT1 = "/raidlockreport";
SLASH_RAIDLOCKREPORT2 = "/rlr";
When I run the code I get "Type '/help' for a listing of a few commands."
Code:
SlashCmdList["RAIDLOCKREPORT"] = function() 
    DEFAULT_CHAT_FRAME:AddMessage("Working"); 
end
SLASH_RAIDLOCKREPORT1 = "/raidlockreport";
SLASH_RAIDLOCKREPORT2 = "/rlr";
Drycoded.
Edit: Assuming the addon where you have that code is actually loading without errors.
  Reply With Quote
04-02-16, 08:29 PM   #3
suipsyco
A Deviate Faerie Dragon
Join Date: Apr 2016
Posts: 13
Thanks that worked! So am I to understand that SlashCmdList[""] need to be a function then?
  Reply With Quote
04-02-16, 08:57 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
A function with a single string parameter if needed.

It could be:
Code:
SlashCmdList["RAIDLOCKREPORT"] = function(msg) 
    if msg then
        DEFAULT_CHAT_FRAME:AddMessage(msg) 
    else
        DEFAULT_CHAT_FRAME:AddMessage("Working") 
    end
end
SLASH_RAIDLOCKREPORT1 = "/raidlockreport";
SLASH_RAIDLOCKREPORT2 = "/rlr";
if you type "/rlr 123" it would print 123.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
04-02-16, 09:04 PM   #5
suipsyco
A Deviate Faerie Dragon
Join Date: Apr 2016
Posts: 13
Gotcha, so, the slash command is working, but the goal of the slash command is to show the frame again after its been closed. Once again, everywhere I check, I need to use the Show() function for the frame. When I run this code, the "Working" message still shows so i know that the slash is working, but the frame doesn't show and when I hit enter to send the command the text stays in the bar.

Also, aside from the book, where can i find these answers so i don't have to ask so often? Google is failing me only giving me poorly descriptive API pages...

Code:
SlashCmdList["RAIDLOCKREPORT"] = function() 
    DEFAULT_CHAT_FRAME:AddMessage("Working");
    UIConfig:Show()
end
SLASH_RAIDLOCKREPORT1 = "/raidlockreport";
SLASH_RAIDLOCKREPORT2 = "/rlr";


local UIConfig = CreateFrame("Frame", "MUI_BuffFrame", UIParent, "BasicFrameTemplateWithInset");
  Reply With Quote
04-02-16, 09:28 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
wowprogramming.com and wowpedia.org are two good sites.

You should be getting an error which is why you're seeing this behaviour so, you need to turn on "Display lua Errors" in the Interface\Help options or better yet get
BugGrabber and BugSack

Anything local needs to be declared before it is called so in this case to create a toggle,
Code:
local UIConfig = CreateFrame("Frame", "MUI_BuffFrame", UIParent, "BasicFrameTemplateWithInset");
UIConfig:SetSize(50, 50)
UIConfig:ClearAllPoints()
UIConfig:SetPoint("CENTER")

SlashCmdList["RAIDLOCKREPORT"] = function() 
    DEFAULT_CHAT_FRAME:AddMessage("Working");
    if not UIConfig:IsShown() then
        UIConfig:Show()
    else
        UIConfig:Hide()
    end
end
SLASH_RAIDLOCKREPORT1 = "/raidlockreport";
SLASH_RAIDLOCKREPORT2 = "/rlr";
Edit: Updated so you can see something.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-02-16 at 09:36 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Slash Commands


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off