WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Wish List (https://www.wowinterface.com/forums/forumdisplay.php?f=15)
-   -   Have /cast and /use Accept spellIDs (https://www.wowinterface.com/forums/showthread.php?t=56729)

Vrul 09-30-18 10:19 AM

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.


All times are GMT -6. The time now is 12:57 AM.

vBulletin © 2019, Jelsoft Enterprises Ltd
© 2004 - 2019 MMOUI