Quantcast Have /cast and /use Accept spellIDs - WoWInterface
Thread Tools Display Modes
09-30-18, 10:19 AM   #1
Vrul
A Frostmaul Preserver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 289
Have /cast and /use Accept spellIDs

If the following code from ChatFrame.lua
Code:
-- We want to prefer spells for /cast and items for /use but we can use either
SecureCmdList["CAST"] = function(msg)
    local action, target = SecureCmdOptionParse(msg);
    if ( action ) then
    	local spellExists = DoesSpellExist(action)
		local name, bag, slot = SecureCmdItemParse(action);
		if ( spellExists ) then
			CastSpellByName(action, target);
		elseif ( slot or GetItemInfo(name) ) then
			SecureCmdUseItem(name, bag, slot, target);
		end
    end
end

SecureCmdList["USE"] = function(msg)
    local action, target = SecureCmdOptionParse(msg);
    if ( action ) then
		local name, bag, slot = SecureCmdItemParse(action);
		if ( slot or GetItemInfo(name) ) then
			SecureCmdUseItem(name, bag, slot, target);
		else
			CastSpellByName(action, target);
		end
    end
end
was replaced with
Code:
-- We want to prefer spells for /cast and items for /use but we can use either
SecureCmdList["CAST"] = function(msg)
    local action, target = SecureCmdOptionParse(msg);
    if ( action ) then
		local spellID = tonumber(action);
		if ( DoesSpellExist(spellID or action) ) then
			if spellID then
				CastSpellByID(spellID, target);
			else
				CastSpellByName(action, target);
			end
		else
			local name, bag, slot = SecureCmdItemParse(action);
			if ( slot or GetItemInfo(name) ) then
				SecureCmdUseItem(name, bag, slot, target);
			end
		end
    end
end

SecureCmdList["USE"] = function(msg)
    local action, target = SecureCmdOptionParse(msg);
    if ( action ) then
		local name, bag, slot = SecureCmdItemParse(action);
		if ( slot or GetItemInfo(name) ) then
			SecureCmdUseItem(name, bag, slot, target);
		else
			local spellID = tonumber(action);
			if spellID then
				CastSpellByID(spellID, target);
			else
				CastSpellByName(action, target);
			end
		end
    end
end
we could use a spellID with /cast or /use which would simplify making locale independent macros/code.
  Reply With Quote

WoWInterface » Developer Discussions » Wish List » Have /cast and /use Accept spellIDs

Thread Tools
Display Modes

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