Can anyone figure out why this function would be ignoring the value of Amount which is passed to DoTradeSkill()? It makes one potion correctly then just stops, the solution eludes me.
if the slash command given is
/mix 5 greater mana
then
Amount = 5
Potion = 'greater mana'
Code:
SlashCmdList['MIX'] = function(msg) MixPotion(msg) end
function MixPotion(msg)
CastSpellByName('Alchemy')
Amount, Potion = GetCmd(msg)
for i = 1, GetNumTradeSkills() do
if strfind(strlower(GetTradeSkillInfo(i)), strlower(Potion)) then
DEFAULT_CHAT_FRAME:AddMessage('Mixing '..Amount..'x '..GetTradeSkillInfo(i)..'.')
DoTradeSkill(i, Amount)
break
end
end
CloseTradeSkill()
end
function GetCmd(msg) -- thanks to Tigerheart for this code from wowwikki
if msg then
local a, b, c = strfind(msg, '(%S+)') -- contiguous string of non-space characters
if a then return c, strsub(msg, b + 2)
else return ""
end
end
end