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.