Thread Tools Display Modes
08-27-14, 06:34 AM   #1
Xíry
A Murloc Raider
Join Date: Aug 2014
Posts: 4
How to use slash commands

Hey guys!

I just started to learn the basics of lua programming. As the second step after "hello world" I wanted to comminicate with my addon. I though the slash commands would be the easiest way. Since my code didn't work I just copy pasted several sample codes that also didn't work. I'm just getting the response: Type "/help" for a listing of a few commands.

Here is a sample from wowpedia, that also didn't work:
Code:
SLASH_HELLOWORLD1, SLASH_HELLOWORLD2 = '/hiw', '/hellow';
local function handler(msg, editBox)
    if msg == 'bye' then
        print('Goodbye, World!')
    else
        print("Hello, World!")
    end
end
SlashCmdList["HELLOWORLD"] = handler; -- Also a valid assignment strategy
What is the problem? My only guess is that could be an out of date method and I'm on a wrong way.

Thanks in advance!
Xíry
  Reply With Quote
08-27-14, 06:57 AM   #2
Sjak
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 13
Originally Posted by Xíry View Post
Hey guys!

I just started to learn the basics of lua programming. As the second step after "hello world" I wanted to comminicate with my addon. I though the slash commands would be the easiest way. Since my code didn't work I just copy pasted several sample codes that also didn't work. I'm just getting the response: Type "/help" for a listing of a few commands.

Here is a sample from wowpedia, that also didn't work:
Code:
SLASH_HELLOWORLD1, SLASH_HELLOWORLD2 = '/hiw', '/hellow';
local function handler(msg, editBox)
    if msg == 'bye' then
        print('Goodbye, World!')
    else
        print("Hello, World!")
    end
end
SlashCmdList["HELLOWORLD"] = handler; -- Also a valid assignment strategy
What is the problem? My only guess is that could be an out of date method and I'm on a wrong way.

Thanks in advance!
Xíry
Are you sure your addon is actually being loaded by the game? The code you posted works fine for me. Try putting a print statement at the top of your lua file and see if anything is actually printed in game.
  Reply With Quote
08-27-14, 07:22 AM   #3
Xíry
A Murloc Raider
Join Date: Aug 2014
Posts: 4
Thank you for your fast reply. It was my really noobish fault. I forgot to load the lua file in the toc file... I'd delete that thread if i could...
  Reply With Quote
08-27-14, 08:59 AM   #4
Sjak
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 13
Originally Posted by Xíry View Post
Thank you for your fast reply. It was my really noobish fault. I forgot to load the lua file in the toc file... I'd delete that thread if i could...
Haha, I'm sure everyone's done similar things before :P. It's often the simplest things that you overlook when something doesn't work.
  Reply With Quote
08-27-14, 10:01 AM   #5
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Sjak View Post
Haha, I'm sure everyone's done similar things before :P.
Here! Guilty. My second step after "hello world" was exactly the same fail. ;D
  Reply With Quote
08-28-14, 03:57 AM   #6
Xíry
A Murloc Raider
Join Date: Aug 2014
Posts: 4
Wow, seems like there's such a great community. I was sure that I'll get a cold shower.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to use 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