Need help with wow classic addon

Hey, I started making wow add-ons very recently and tried to make an add-on were my character would cast arcane intellect and frost armor if i typed /b or /buffs. It won’t work, and I’ve tried everything i know. If someone could tell me how to get it working that would be great.
lua file:
SLASH_BUFFS1 = “/b”
SLASH_BUFFS2 = “/buffs”

SlashCmdList[“BUFFS”] = local function buffshandler()
CastSpell(27126, arcane) --arcane intelect
CastSpell(31256, frost) --frost armor
end

SlashCmdList[“BUFFS”] = buffsHandler

toc file:

Interface: 20504

Title: BUFFS

Notes: The player can type /b or /buffs to get buffs

Author: CloseGanelon

Version: 0.0.1

Buffs.lua

Dont roast me too hard lol

i don’t think most of us are skilled in that field. I suspect a discord for addon makers might be a better bet… maybe a custom WA can accomplish this?

thanks for the reply, ill check it out.

I’m not sure if CastSpell is a function that works… I know there’s a CastSpellByName function, but I don’t think it’s useable for casting most spells.

For example, you can test whether something works using the /script command, ex:

/script OpenAllBags()

This should open all your bags, and

/script CloseAllbags()

should close them.

But, if you try to run something like:

/script CastSpellByName("Arcane Intellect(Rank 1)")

You’ll get a popup saying, “A macro script has been blocked from an action only available to the Blizzard UI.” AFAIK, you cannot use an addon to cast spells.


EDIT:

Also, I think there may be some typos in your addon. For example, you seem to be attempting to assign a function as the value to the SlashCmdList:

SlashCmdList[“BUFFS”] = local function buffshandler()
  CastSpell(27126, arcane) --arcane intelect
  CastSpell(31256, frost) --frost armor
end

Whereas, afaik, you would give the function declaration, then assign the function as a name to the SlashCmdList:

local function buffshandler()
  CastSpell(27126, arcane) --arcane intelect
  CastSpell(31256, frost) --frost armor
end

SlashCmdList[“BUFFS”] = buffshandler

Here’s a working example addon that just opens (/open) and closes (/close) all bags that may be useful as a starting point:

SLASH_OPEN1 = "/open"
SLASH_CLOSE1 = "/close"

local function openBags()
    OpenAllBags()
end

local function closeBags()
    CloseAllBags()
end

SlashCmdList["OPEN"] = openBags;
SlashCmdList["CLOSE"] = closeBags;

Thank you, as i said i am not very experienced in lua and wow addons. :slight_smile:
Aslo, i found the CastSpell in a fan documentation.

1 Like