Thread Tools Display Modes
11-22-09, 07:46 AM   #1
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
Slash commands handlers and automation

Hello, I'm having a problem with my slash command handler, here's the part of code that bothers me

Code:
function stCore:SlashHandler(name)
 if(name) then
	if getglobal("stText_"..name) then
		local f = _G["stText_"..name]
--	 	Custom slash commands
		if f.Slash then 
			f:Slash()
--		Normal slash commands	
		else
			if f.bg:IsShown() then
				f.bg:Hide()
				f:EnableMouse"false"
				print("|cff00efffstText: |r"..name.." module locked")
			else
				f.bg:Show()
				f:EnableMouse"true"
				print("|cff00efffstText: |r"..name.." module unlocked")
			end
		end
	end
 end
end
SLASH_STTEXT1 = "/sttext"
SLASH_STTEXT2 = "/stt"
SlashCmdList["STTEXT"] = stCore.SlashHandler
My plugins are named Clock, Memory (and others but here are the ones I testing with because Clock is a normal plugin, and Memory is a custom one)

If type /stt Clock then it throws me an error telling me that :
Code:
attempt to concatenate local 'name' (a table value)
Here's the line with the problem
Code:
if getglobal("stText_"..name) then
But if I type /run stCore:SlashHandler"Clock" then it works

So if someone is understanding what the problem can be
__________________
  Reply With Quote
11-22-09, 08:03 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
The error message pretty much tells you what it is .. track back the value that ultimately gets passed to Slash Handler. It is a table of values by the sound of it. Your test is passing a single value but perhaps your addon is passing more than just a value.

Try print(name) and see what it results out as. Once you find out why it is passing a table value or how you can get the value you want out of the table you will be able to correct the problem.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
11-22-09, 08:04 AM   #3
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
stCore.SlashHandler ~= stCore:SlashHandler

Just did a quick google search and this will probably help you http://www.lua.org/pil/16.html .

Last edited by Slakah : 11-22-09 at 08:18 AM.
  Reply With Quote
11-22-09, 08:46 AM   #4
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
Thanks a lot, I just defined the function as stCore.SlashCommand and it worked perfectly
__________________
  Reply With Quote
11-22-09, 12:46 PM   #5
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
You also want to replace getglobal("whatever") with _G["whatever"].
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Slash commands handlers and automation


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