Thread Tools Display Modes
08-02-11, 11:36 AM   #1
SEnergy
Banned
Join Date: Aug 2011
Posts: 2
[Help] My first addon

Hi, I decided to make my first addon, I wanted to create addon that if u will say "/seon" it will change color of your text and if u say "/seoff" it will return it back to normal, but when I test it in-game it just don't works, I don't get any error or something, only that "this command does not exist, say "/help" for command list" or something like this, it don't even send message that is added at top when I login, here is my addon:

--this is for 3.3.5a

SEnergy.lua
Code:
SLASH_SECMDON1 = "/seon"
SLASH_SECMDOFF1 = "/seoff"
DEFAULT_CHAT_FRAME:AddMessage("|cff404040SEnergy has been activated!\124r.");
scm = SendChatMessage
Thing[0] = msg;
Thing[1] = "\124cffCC0000\124Hitem:19:0:0:0:0:0:0:0\124h(SEnergy!): \124cffFF6600\124Hitem:19:0:0:0:0:0:0:0\124h" ..msg.. "\124h\124r";
SECMDONOFF = 0;

SlashCmdList["SECMDON"] = function()
	if(SECMDONOFF = 1) then
		DEFAULT_CHAT_FRAME:AddMessage("|cff404040ChatColor is already ON\124r.");
	else if(SECMDONOFF = 0) then
		SECMDONOFF = 1;
	end
end

SlashCmdList["SECMDOFF"] = function()
	if(SECMDONOFF = 0) then
		DEFAULT_CHAT_FRAME:AddMessage("|cff404040ChatColor is already OFF\124r.");
	else if(SECMDONOFF = 1) then
		SECMDONOFF = 0
	end
end

function SendChatMessage(msg, type, language, chan)
	scm(Thing[SECMDONOFF], type, language, chan);
end

SEnergy.toc
Code:
## Interface: 30300
## Title: |cffEE4000SE|cff404040nergy
## Author: SEnergy
## Version: 1.00
## eMail:
## DefaultState: Enabled
## LoadOnDemand: 0
SEnergy.lua
P.S.: This is rewrite of my first working "addon" from one book (I don't remember name), maybe it will help so here it is:
Code:
SLASH_CAU1 = "/cau"
SlashCmdList["CAU"] = function(self, txt)
	if UnitExists("target") then
		SendChatMessage(UnitName("target") .. " si zmrd!", "SAY")
	else
		SendChatMessage("Caute zmrdi!")
	end
end
Code:
## Interface: 30300
## Title: Hey There!
## Notes: Provides slash commands to geet other players

HeyThere.lua
 
08-02-11, 12:03 PM   #2
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
I'm trying to debug your code, but it looks really confusing to me. Maybe I'm just tired.

I can't seem to find the reason why the /command wouldn't actually exist. However, try to place this:

Code:
SLASH_SECMDON1 = "/seon"
SLASH_SECMDOFF1 = "/seoff"
after your functions, instead of at the top.

By the way, '=' in a condition needs to replaced by '=='. Like this:

Code:
if(SECMDONOFF == 1)
Also, what's this?

Code:
function SendChatMessage(msg, type, language, chan)
	scm(Thing[SECMDONOFF], type, language, chan);
end
Is it your intention to overwrite the default SendChatMessage function? That's not a very good idea.

Also, I'm not quite sure if I understood the intention of your addon correctly, but you can't send coloured chat messages to other people.

Last edited by Haleth : 08-02-11 at 12:07 PM.
 
08-02-11, 12:04 PM   #3
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by SEnergy View Post
Code:
SlashCmdList["SECMDON"] = function()
	if(SECMDONOFF = 1) then
		DEFAULT_CHAT_FRAME:AddMessage("|cff404040ChatColor is already ON\124r.");
	else if(SECMDONOFF = 0) then
		SECMDONOFF = 1;
	end
end
Can you turn on Lua errors or get BugSack/Swatter?

Originally Posted by SEnergy View Post
--this is for 3.3.5a
uhmm ..

Last edited by Ketho : 08-02-11 at 12:07 PM.
 
08-02-11, 12:18 PM   #4
SEnergy
Banned
Join Date: Aug 2011
Posts: 2
Originally Posted by Haleth View Post
I'm trying to debug your code, but it looks really confusing to me. Maybe I'm just tired.

I can't seem to find the reason why the /command wouldn't actually exist. However, try to place this:

Code:
SLASH_SECMDON1 = "/seon"
SLASH_SECMDOFF1 = "/seoff"
after your functions, instead of at the top.

By the way, '=' in a condition needs to replaced by '=='. Like this:

Code:
if(SECMDONOFF == 1)
Also, what's this?

Code:
function SendChatMessage(msg, type, language, chan)
	scm(Thing[SECMDONOFF], type, language, chan);
end
Is it your intention to overwrite the default SendChatMessage function? That's not a very good idea.

Also, I'm not quite sure if I understood the intention of your addon correctly, but you can't send coloured chat messages to other people.
I'm trying to convert this macro
Code:
/run if(not scm) then scm = SendChatMessage; end; function SendChatMessage(msg, type, lang, chan);scm("\124cffCC0000\124Hitem:19:0:0:0:0:0:0:0\124h(SEnergy!): \124cffFF6600\124Hitem:19:0:0:0:0:0:0:0\124h" ..msg.. "\124h\124r", type, lang, chan);end
into addon, as u can see this macro is working, so I CAN send colored messages to players: http://filebeam.com/3eb4841d1c5f7b14...8ccd191a53.jpg

and yes, I'm trying to overwrite default SendChatMessage function

edit: I tried to place commands under functions and replaced '=' with '==' in 'if' (didn't noticed that :P) but it's still not working

Last edited by SEnergy : 08-02-11 at 12:22 PM.
 
08-02-11, 12:32 PM   #5
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
On WoWInterface, we do not support the use of private servers, and we won't be able to help you create addons for them either.

Sending coloured messages is not possible on live realms.

Closing this.
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » [Help] My first addon


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