Thread Tools Display Modes
10-11-06, 12:31 AM   #1
Himar
A Murloc Raider
Join Date: Oct 2006
Posts: 4
Post Help, DoTradeSkill() ignoring quantity

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

Last edited by Himar : 10-13-06 at 04:10 PM.
  Reply With Quote
10-13-06, 04:25 PM   #2
wmrojer
A Deviate Faerie Dragon
 
wmrojer's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 13
It's because you close the tradeskill window. Try it manually by makeing 5 and closeing the window before it's done. It will make the one in progress, the quit.
  Reply With Quote
10-13-06, 05:16 PM   #3
Himar
A Murloc Raider
Join Date: Oct 2006
Posts: 4
You sir, are my new favourite person. Bang on... I was looking at everything under the sun except that CloseTradeSkill. Thank you!
  Reply With Quote
10-14-09, 01:18 AM   #4
MadjackMcMad
A Kobold Labourer
Join Date: Oct 2009
Posts: 1
wmrojer: good find!

You may want to actually move the CloseTradeskillWindow() call to right above CastSpellByName('Alchemy'). If you don't, your macro will fumble if the window is already open; the cast will close the window.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » DoTradeSkill(index, amount) not working for me


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