Thread: Slash Commands
View Single Post
06-30-09, 05:50 AM   #7
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Slakah View Post
They're global functions so it wont make a difference.
Yes it will; since the reference will be nil when the code runs, it doesn't matter how they're defined later. You're thinking of a slightly different compile-time error; but in this case the code is top-level and those lines will actually *run* while the function names are still nil references.

However, it would be better if they were not global anyway:

Code:
local function toggleHelm()
     ShowHelm(not ShowingHelm())
end

local function toggleCloak()
     ShowCloak(not ShowingCloak())
end


SLASH_TOGGLEHELM1 = "/toggleHelm"
SLASH_TOGGLECLOAK1 = "/toggleCloak"

SlashCmdList["TOGGLEHELM"] = toggleHelm
SlashCmdList["TOGGLECLOAK"] = toggleCloak

Last edited by Akryn : 06-30-09 at 05:56 AM.
  Reply With Quote