Download
(6 Kb)
Download
Updated: 12-11-08 10:38 AM
Pictures
File Info
Updated:12-11-08 10:38 AM
Created:unknown
Downloads:9,278
Favorites:54
MD5:
Auto Buy Reagents  Popular! (More than 5000 hits)
Version: 0.99
by: tsukeru [More]
Auto Buy Reagents is a simple mod for World of Warcraft. The mod buys class specific reagents for the user when talking to a merchant capable of selling the reagents. This mod buys up to a number of reagents specified by the user and only buys more when there are less than the number specified. All classes are supported (except classes that do not need reagents) as the mod is dynamic and adjusts to the class being played. There are still a few bugs and may not work properly all the time, this is expected to be ironed out in the next couple of days. The mod has a simple user interface that you can access with /autobuyreagents or /abr commands.

What this mod does:
  • Buys a number of reagents for class spells/abilities.
  • Keeps that number of reagents in your inventory at all times.
    Ex) I want to have 40 arcane runes at all times, I use 15 out of my 40, the next time I talk to a merchant I'll buy 15 more runes so I have a total of 40.
  • Simple interface to easily adjust values.
Things to do:
  • Document code.
  • Create a Fubar extension
  • Add support for Rogue poisons
  • Use Blizzards UI for interface.

This is the same mod that is under the Ace/Inventory category, it was wrongly placed upon upload. I apologize for the lapse in judgement.

--Window users only--
You'll see an additional directory in the zip file if you are a Windows user. This is a hidden file that my Mac puts in it's zip files. Do not put it in your addons folder, it is not required for any functionality. It's just a settings file that Mac's automatically put in zips. Sorry for the confusion.
0.99 - Localized a lot of my globals to the file only. Removed debugging printout that may cause unnecessary errors. Running out of numbers to increment for version....

0.98 - Definitely fixed druids (I play tested several times this time!). Priest should work now but reagents may be wrong. Priests, please report any problems you find.

0.97 - Fixed Druid and possibly Priest errors.

0.96 - Fixed Paladin errors and renamed several methods.

0.9 Stable - Updated to Wraith of Lich King. Druid bugs are fixed and priests were added.

0.87 Beta - Fixed a minor error.
Optional Files (0)


Archived Files (4)
File Name
Version
Size
Author
Date
0.98
6kB
tsukeru
12-10-08 04:16 PM
0.97
6kB
tsukeru
12-10-08 01:34 PM
0.96
6kB
tsukeru
12-04-08 09:23 AM
0.9 Stable
5kB
tsukeru
11-26-08 10:18 PM


Post A Reply Comment Options
Unread 02-12-10, 07:27 PM  
Conzar
A Kobold Labourer

Forum posts: 0
File comments: 9
Uploads: 0
Re: Death Knight fix.

Originally posted by Shazear
..."DEATHKNIGHT"...
Shaze, you are a star - worked out the reagent bit, but couldn't figure this one out. Guess I should have come back here after rolling my Death Knight... or should that be Deathknight? :-D
Conzar is offline Report comment to moderator  
Reply With Quote
Unread 11-08-09, 10:14 PM  
jerryb1988
A Kobold Labourer

Forum posts: 0
File comments: 2
Uploads: 0
** Part 2 of 2 **

AutoBuyReagents.xml

Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\..\FrameXML\UI.xsd">
<Script file="AutoBuyReagents.lua" />
<!-- OnLoad Frame -->
<Frame name="LoadFrame" hidden="true">
	<Scripts>
		<OnLoad>
			AutoBuyReagents_OnLoad();
		</OnLoad>
		<OnEvent>
			AutoBuyReagents_OnEvent();
		</OnEvent>
	</Scripts>
</Frame>


<!-- Main Frame -->
<Frame name="AutoBuyReagentsFrame" enableMouse="true" movable="true" hidden="true" >
	<Size> 
		<AbsDimension x="300" y="250"/> 
	</Size>
	<Anchors>
		<Anchor point="CENTER"/>
	</Anchors>
	<TitleRegion>
		<Size>
			<AbsDimension x="300" y="20" />
		</Size>
		<Anchors>
			<Anchor point="TOP" />
			<Anchor point="CENTER" />
		</Anchors>
	</TitleRegion>
	<Backdrop bgFile="Interface\TutorialFrame\TutorialFrameBackground" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
		<EdgeSize>
			<AbsValue val="16"/>
		</EdgeSize>
		<TileSize>
			<AbsValue val="32"/>
		</TileSize>
		<BackgroundInsets>
			<AbsInset left="5" right="5" top="5" bottom="5"/>
		</BackgroundInsets>
	</Backdrop>
	
	<Layers>
		<Layer level="BACKGROUND">
			<Texture>
				<Color r="0.0" g="0.0" b="0.0" a="0.8" />
			</Texture>
		</Layer>
	<!-- Removing top border
		<Layer name="Highlight1" level="BORDER">		
			<Texture>
				<Color r="0.8" g="0.0" b="0.0" a="0.8" />
				<Size>
					<AbsDimension x="285" y="20" />
				</Size>
				<Anchors>
					<Anchor point="TOP" >
						<Offset><AbsDimension x="1.5" y="-11" /> </Offset>
					</Anchor>
					<Anchor point="CENTER" />
				</Anchors>
			</Texture>
		</Layer>
	-->
		<Layer name="Layer1" level="OVERLAY">
			<FontString name="Title" inherits="ChatFontNormal" text="Auto Buy Reagents">
				<Color r="0.7" g="0.0" b="0.0" a="1.0" />
				<Anchors>
					<Anchor point="TOP">
						<Offset><AbsDimension x="0" y="-8" /> </Offset>
					</Anchor>
					<Anchor point="CENTER" />
				</Anchors>
				<Shadow><offset><AbsDimension x="1" y="1"/></offset><color r="0" g="0" b="0"/></Shadow>
			</FontString>
		
			<FontString name="Description" inherits="ChatFontNormal" justifyH="LEFT" text="If you want to have ABR buy the reagent for your |nclass, check the box of the reagent and input a |nnumber. Remember to hit Save before you close!" >
				<Color r="1.0" g="1.0" b="1.0" a="1.0" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset><AbsDimension x="10" y="-30" /> </Offset>
					</Anchor>
				</Anchors>
			</FontString>
		
			<FontString name="ReagentFont1" inherits="ChatFontNormal" justifyH="LEFT">
				<Size>
					<AbsDimension x="180" y="20" />
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset><AbsDimension x="50" y="-100" /></Offset>
					</Anchor>
				</Anchors>
			</FontString>
			
			<FontString name="ReagentFont2" inherits="ChatFontNormal" justifyH="LEFT">
				<Size>
					<AbsDimension x="180" y="20" />
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset><AbsDimension x="50" y="-130" /></Offset>
					</Anchor>
				</Anchors>
			</FontString>
			
			<FontString name="ReagentFont3" inherits="ChatFontNormal" justifyH="LEFT">
				<Size>
					<AbsDimension x="180" y="20" />
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset><AbsDimension x="50" y="-160" /></Offset>
					</Anchor>
				</Anchors>
			</FontString>
		</Layer>
	</Layers>
	<Frames>
		<!-- Reagent Check Button 1 -->
		<CheckButton name="ReagentCheckButton1" inherits="OptionsCheckButtonTemplate" checked="true">
			<Anchors>
				<Anchor point="TOPLEFT">
					<Offset>
						<AbsDimension x="10" y="-95"></AbsDimension>
					</Offset>
				</Anchor>
			</Anchors>
		</CheckButton>
		
		<!-- Reagent Num Box 1 -->
		<EditBox name="ReagentNumBox1" letters="5" numeric="true" id="15">
			<Size>
				<AbsDimension x="40" y="32"></AbsDimension>
			</Size>
			<Anchors>
				<Anchor point="TOPLEFT">
					<Offset>
						<AbsDimension x="235" y="-95"></AbsDimension>
					</Offset>
				</Anchor>
			</Anchors>
			<Layers>
				<Layer level="BACKGROUND">
					<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Left">
						<Size>
							<AbsDimension x="30" y="32"></AbsDimension>
						</Size>
						<Anchors>
							<Anchor point="LEFT">
								<Offset>
									<AbsDimension x="-10" y="0"></AbsDimension>
								</Offset>
							</Anchor>
						</Anchors>
						<TexCoords left="0" right="0.2" top="0" bottom="1.0"></TexCoords>
					</Texture>
					<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Right">
						<Size>
							<AbsDimension x="30" y="32"></AbsDimension>
						</Size>
						<Anchors>
							<Anchor point="RIGHT">
								<Offset>
									<AbsDimension x="10" y="0"></AbsDimension>
								</Offset>
							</Anchor>
						</Anchors>
						<TexCoords left="0.7" right="1.0" top="0" bottom="1.0"></TexCoords>
					</Texture>
				</Layer>
			</Layers>
			<FontString inherits="ChatFontNormal" />
		</EditBox>
		
		<!-- Reagent Check Button 2 -->
		<CheckButton name="ReagentCheckButton2" inherits="OptionsCheckButtonTemplate" checked="true">
			<Anchors>
				<Anchor point="TOPLEFT">
					<Offset>
						<AbsDimension x="10" y="-125"></AbsDimension>
					</Offset>
				</Anchor>
			</Anchors>
		</CheckButton>
		
		<!-- Reagent Num Box 2 -->
		<EditBox name="ReagentNumBox2" letters="5" numeric="true" id="16">
			<Size>
				<AbsDimension x="40" y="32"></AbsDimension>
			</Size>
			<Anchors>
				<Anchor point="TOPLEFT">
					<Offset>
						<AbsDimension x="235" y="-125"></AbsDimension>
					</Offset>
				</Anchor>
			</Anchors>
			<Layers>
				<Layer level="BACKGROUND">
					<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Left">
						<Size>
							<AbsDimension x="30" y="32"></AbsDimension>
						</Size>
						<Anchors>
							<Anchor point="LEFT">
								<Offset>
									<AbsDimension x="-10" y="0"></AbsDimension>
								</Offset>
							</Anchor>
						</Anchors>
						<TexCoords left="0" right="0.2" top="0" bottom="1.0"></TexCoords>
					</Texture>
					<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Right">
						<Size>
							<AbsDimension x="30" y="32"></AbsDimension>
						</Size>
						<Anchors>
							<Anchor point="RIGHT">
								<Offset>
									<AbsDimension x="10" y="0"></AbsDimension>
								</Offset>
							</Anchor>
						</Anchors>
						<TexCoords left="0.7" right="1.0" top="0" bottom="1.0"></TexCoords>
					</Texture>
				</Layer>
			</Layers>
			<FontString inherits="ChatFontNormal" />
		</EditBox>
		
		<!-- Reagent Check Button 3 -->
		<CheckButton name="ReagentCheckButton3" inherits="OptionsCheckButtonTemplate" checked="true">
			<Anchors>
				<Anchor point="TOPLEFT">
					<Offset>
						<AbsDimension x="10" y="-155"></AbsDimension>
					</Offset>
				</Anchor>
			</Anchors>
		</CheckButton>
		
		<!-- Reagent Num Box 3 -->
		<EditBox name="ReagentNumBox3" letters="5" numeric="true" id="17">
			<Size>
				<AbsDimension x="40" y="32"></AbsDimension>
			</Size>
			<Anchors>
				<Anchor point="TOPLEFT">
					<Offset>
						<AbsDimension x="235" y="-155"></AbsDimension>
					</Offset>
				</Anchor>
			</Anchors>
			<Layers>
				<Layer level="BACKGROUND">
					<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Left">
						<Size>
							<AbsDimension x="30" y="32"></AbsDimension>
						</Size>
						<Anchors>
							<Anchor point="LEFT">
								<Offset>
									<AbsDimension x="-10" y="0"></AbsDimension>
								</Offset>
							</Anchor>
						</Anchors>
						<TexCoords left="0" right="0.2" top="0" bottom="1.0"></TexCoords>
					</Texture>
					<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Right">
						<Size>
							<AbsDimension x="30" y="32"></AbsDimension>
						</Size>
						<Anchors>
							<Anchor point="RIGHT">
								<Offset>
									<AbsDimension x="10" y="0"></AbsDimension>
								</Offset>
							</Anchor>
						</Anchors>
						<TexCoords left="0.7" right="1.0" top="0" bottom="1.0"></TexCoords>
					</Texture>
				</Layer>
			</Layers>
			<FontString inherits="ChatFontNormal" />
		</EditBox>
		
		<!-- Save settings button -->
		<Button name="SaveSettings" inherits="UIPanelButtonTemplate" text="Save Settings">
			<Size>
				<AbsDimension x="120" y="22"/>
			</Size>
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="AutoBuyReagentsFrame" >
						<Offset>
							<AbsDimension x="40" y="-205" />
						</Offset>
					</Anchor>
				</Anchors>
			<Scripts>
				<OnClick> AutoBuyReagents_SaveButtonPressed(); </OnClick>
			</Scripts>
		</Button>
		
		<!-- Close button -->
		<Button name="Close" inherits="UIPanelButtonTemplate" text="Close">
			<Size>
				<AbsDimension x="80" y="22"/>
			</Size>
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="AutoBuyReagentsFrame">
						<Offset>
							<AbsDimension x="175" y="-205" />
						</Offset>
					</Anchor>
				</Anchors>
			<Scripts>
				<OnClick> AutoBuyReagents_HideFrame( getglobal( "AutoBuyReagentsFrame" ) ) </OnClick>
			</Scripts>
		</Button>	
	</Frames>
	<Scripts>
		<OnShow> AutoBuyReagents_LoadPresets(); </OnShow>
	</Scripts>
</Frame>
</Ui>
Last edited by jerryb1988 : 11-08-09 at 10:40 PM.
jerryb1988 is offline Report comment to moderator  
Reply With Quote
Unread 11-08-09, 10:14 PM  
jerryb1988
A Kobold Labourer

Forum posts: 0
File comments: 2
Uploads: 0
** Part 1 of 2 **

Heres my edited AutoBuyReagents.lua

Changes:
+Corpse dust for Death knights
+Basic hunter bullets/arrows based on hunters level

Code:
local classTable = {};
local indexTable = { "DEATHKNIGHT", "DRUID", "HUNTER", "MAGE", "PALADIN", "PRIEST", "ROGUE", "SHAMAN", "WARLOCK", "WARRIOR" }; -- Line changed by jerryb1988
local rDK = { 37201 }; -- Line changed by jerryb1988
local rDruid = {};
local rHunter = {}; -- Line changed by jerryb1988
local rMage = { 17020, 17031, 17032 };
local rPali = { 17033, 21177 };
local rPriest = {};
local rRogue = nil;
local rShaman = { 17030 };
local rWarlock = { 5565, 16583 };
local rWarrior = nil;
local reagents = { rDK, rDruid, rHunter, rMage, rPali, rPriest, rRogue, rShaman, rWarlock, rWarrior };

function AutoBuyReagents_OnLoad()
	SLASH_AUTOBUYREAGENTS1   = "/autobuyreagents";
	SLASH_AUTOBUYREAGENTS2 = "/abr";
	SlashCmdList["AUTOBUYREAGENTS"] = function(msg)
		AutoBuyReagents_SlashCommandHandler(msg);
	end
		
	this:RegisterEvent("ADDON_LOADED");
	this:RegisterEvent("VARIABLES_LOADED");
	this:RegisterEvent("MERCHANT_SHOW");
	this:RegisterEvent("PLAYER_LOGIN");
		--this:RegisterEvent("MERCHANT_UPDATE");
end


function AutoBuyReagents_OnEvent()
	if( event == "ADDON_LOADED" and arg1== "AutoBuyReagents" ) then
		if( reagentTable == nil ) then
			reagentTable = {-1,-1,-1};
		end
		
		AutoBuyReagents_Out("Auto Buy Reagents loaded. Use /autobuyreagents or /abr to access the setup screen.");
	end
	
	if( event == "PLAYER_LOGIN" ) then
		AutoBuyReagents_DruidReagents();
		AutoBuyReagents_PriestReagents();
		AutoBuyReagents_HunterReagents();
		
		classTable = AutoBuyReagents_FindTable( AutoBuyReagents_FindClass() );
	end
	
	if( event == "MERCHANT_SHOW" ) then
		if( AutoBuyReagents_DoesMerchantHaveReagents() ) then
			AutoBuyReagents_GetCurrentReagents();
			
			AutoBuyReagents_BuyReagents();
		end
	end
end


function AutoBuyReagents_SlashCommandHandler( msg )
	local frame = getglobal( "AutoBuyReagentsFrame" );
	
	if( msg == "" ) then
		AutoBuyReagents_HideFrame( frame );
	end	
end


function AutoBuyReagents_LoadPresets()
	if( classTable ~= nil ) then
		local numReagents = getn(classTable);
		
		for i = 1, getn(classTable) do
			local textBox = getglobal( "ReagentFont" .. i );
			local editBox = getglobal( "ReagentNumBox" .. i );
			local checkBox = getglobal( "ReagentCheckButton" .. i );


			textBox:SetText( AutoBuyReagents_GetItemName( classTable[i]) );
			
			if( reagentTable[i] == -1 ) then
				editBox:SetText( 0 )
			else
				editBox:SetText( reagentTable[i] );
			end
			
			if( reagentTable[i] == -1 ) then
				checkBox:SetChecked( false );
			end
				
		end
		
		AutoBuyReagents_resetBoxes(numReagents);
		
	else
		AutoBuyReagents_Out("Your class has no reagents.");
	end
end


function AutoBuyReagents_resetBoxes( num )
	local checkBox, inputBox;
	
	for i = 1, num do
		checkBox = getglobal( "ReagentCheckButton" .. i );
		inputBox = getglobal( "ReagentNumBox" .. i );
		checkBox:Show();
		inputBox:Show();
	end
				
	for i = num+1, 3 do
		checkBox = getglobal( "ReagentCheckButton" .. i );
		inputBox = getglobal( "ReagentNumBox" .. i );
		checkBox:Hide();
		inputBox:Hide();
	end
	
end




function AutoBuyReagents_Out(text)
	DEFAULT_CHAT_FRAME:AddMessage(text);
end


----- BEGIN added by jerryb1988
function AutoBuyReagents_HunterReagents()
	local lvl = UnitLevel("Player");

	if (AutoBuyReagents_FindClass() == "HUNTER") then
		if (lvl >= 1 and lvl < 10) then rHunter[1] = 2516; rHunter[2] = 2512;
		elseif (lvl >= 10 and lvl < 25) then rHunter[1] = 2519; rHunter[2] = 2515;
		elseif (lvl >= 25 and lvl < 40) then rHunter[1] = 3033; rHunter[2] = 3030;
		elseif (lvl >= 40 and lvl < 55) then rHunter[1] = 11284; rHunter[2] = 11285;
		elseif (lvl >= 55 and lvl < 65) then rHunter[1] = 28060; rHunter[2] = 28053;
		elseif (lvl >= 65 and lvl < 75) then rHunter[1] = 28061; rHunter[2] = 28056;
		elseif (lvl >= 75 and lvl < 85) then rHunter[1] = 41584; rHunter[2] = 41586;
		end
	end

end
----- END added by jerryb1988


function AutoBuyReagents_DruidReagents()
	local rank1 =  ({ GetSpellInfo( "Rebirth" )})[2];
	local rank2 = ({ GetSpellInfo( "Gift of the Wild" )})[2];
	local lvl = UnitLevel("player");
	
	if( AutoBuyReagents_FindClass() == "DRUID" ) then
		if( lvl >= 20 and rank1 ~= nil ) then
			if( rank1 == "Rank 1" ) then rDruid[1] = 17034;
			elseif( rank1 == "Rank 2" ) then rDruid[1] = 17035;
			elseif( rank1 == "Rank 3" ) then rDruid[1]= 17036;
			elseif( rank1 == "Rank 4"  ) then rDruid[1] = 17037;
			elseif( rank1 == "Rank 5"  ) then rDruid[1] = 17038;
			elseif( rank1 == "Rank 6"  ) then rDruid[1]= 22147;
			elseif( rank1 == "Rank 7" ) then rDruid[1] = 44614;
			end
		end
	
		if( lvl >= 50 and rank2 ~= nil ) then 				
			if( rank2 == "Rank 1" ) then rDruid[2] = 17021;
			elseif( rank2 == "Rank 2" ) then rDruid[2]= 17026;
			elseif( rank2 == "Rank 3" ) then rDruid[2] = 22148;
			elseif( rank2 == "Rank 4" ) then rDruid[2] = 44605;
			end
		end
	end
end


function AutoBuyReagents_PriestReagents()
	local iterator = 1;
	local rank1 = ({ GetSpellInfo( "Prayer of Fortitude" )})[2];
	local rank2 = ({ GetSpellInfo( "Prayer of Spirit")})[2];
	local rank3 = ({ GetSpellInfo( "Prayer of Shadow Protection")})[2];
		
	if( AutoBuyReagents_FindClass() == "PRIEST" ) then
		if( rank1 ~= nil ) then
			if( rank1 == "Rank 1") then
				rPriest[iterator] = 17028;
			elseif( rank1 == "Rank 2" or rank1 == "Rank 3") then
				rPriest[iterator] = 17029;
			elseif( rank1 == "Rank 4") then
				rPriest[iterator] = 44615;
			end
			
			iterator = iterator + 1;
		end
		
		if( rank2 ~= nil ) then
			if( rank2 == "Rank 1" or rank2 == "Rank 2" ) then
				if( rank1 == nil ) then
					rPriest[iterator] = 17029;
				elseif( rank1 ~= "Rank 2" or rank1 ~= "Rank 3") then
					rPriest[iterator] = 17029;
				end
			end
			
			if( rank2 == "Rank 3" ) then
				if( rank1 == nil ) then
					rPriest[iterator] = 44615;
				elseif( rank1 ~= "Rank 4" ) then
					rPriest[iterator] = 44615;
				end
			end
			
			iterator = iterator + 1;
		end
		
		if( rank3 ~= nil ) then
			if( rank3 == "Rank 1" or rank3 == "Rank 2" ) then
				if( rank1 == nil and (rank2 ~= "Rank 1" or rank2 ~= "Rank 2" )) then
					rPriest[iterator] = 17029;
				elseif( rank1 ~= "Rank 2" or rank1 ~= "Rank 3") then
					rPriest[iterator] = 17029;
				end
			end
			
			if( rank3 == "Rank 3" ) then
				if( rank1 == nil and rank2 ~= "Rank 3" ) then
					rPriest[iterator] = 44615;
				elseif( rank1 ~= "Rank 4" and rank2 ~= "Rank 4") then
					rPriest[iterator] = 44615;
				end
			end
		end
	end
end


function AutoBuyReagents_HideFrame( frame )
	if( frame:IsVisible()) then				
		frame:Hide();
	else
		frame:Show();
	end
end


function AutoBuyReagents_FindTable( class )
	local tbl = 0;
	
	for i = 1, # indexTable do
		if( class == indexTable[i] ) then
			tbl = i;
		end
	end
	
	if( tbl == 0 ) then
		AutoBuyReagents_Out( "Cannot Determine Class Error") ;
		return nil;
	else
		return reagents[tbl];
	end
end


function AutoBuyReagents_FindClass()
	return ({UnitClass("player")})[2];
end




function AutoBuyReagents_GetItemName( var )
	item =  {GetItemInfo( var )};
	return item[1];
end


function AutoBuyReagents_SaveButtonPressed()
	local Paliflag = false;


	if( AutoBuyReagents_FindClass() == "PALADIN" ) then
		Paliflag = true;
	end
	
	if( Paliflag ) then
		for i = 1, # classTable do
			local checkBox = getglobal( "ReagentCheckButton" .. i );
			local textBox = getglobal( "ReagentNumBox" .. i );
			local num = textBox:GetText();
			local modBy = 0;
			
			if( checkBox:GetChecked() ) then
				if( classTable[i] == 21177 ) then
					modBy = 20;
					
					if( mod(num,modBy) == 0 ) then
						reagentTable[i] = textBox:GetText();
					else
						textBox:SetText( reagentTable[i] .. "" );					
						message( "ABR: " .. AutoBuyReagents_GetItemName( classTable[i] ) .. " can only be bought in stacks of 20. Make all divisible by 20 (20, 40, etc.)");
					end
				else
					reagentTable[i] = textBox:GetText();
				end
			end
		end
	else  
		reagentTable[1] = ReagentNumBox1:GetText();
		reagentTable[2] = ReagentNumBox2:GetText();
		reagentTable[3] = ReagentNumBox3:GetText();
	end
end


--num refers to the index of the classTable
function AutoBuyReagents_GetCurrentReagents()
	numReagentsTable = {};


	if classTable ~= nil then
		for i = 1, # classTable do
			numReagentsTable[i] = 0;
		
			for bag = 4, 0, -1 do
				local size = GetContainerNumSlots(bag);
				
				if (size > 0) then
					for slot = 1, size, 1 do					
						if( GetContainerItemLink(bag, slot) ~= nil ) then
							local itemName = AutoBuyReagents_GetItemName( GetContainerItemLink(bag, slot) );
							local reagentName = AutoBuyReagents_GetItemName( classTable[i] );
							local _,itemCount = GetContainerItemInfo(bag, slot);
							
							if( itemName == reagentName ) then
								numReagentsTable[i] = numReagentsTable[i] + itemCount;
							end
						end
					end
				end
			end
		end
	end
end


function AutoBuyReagents_DoesMerchantHaveReagents()
	local booleanReagentsTable = {false, false, false};
	merchantIndexes = {};
	
	for i = 1, # classTable do
		for index = 0, GetMerchantNumItems() do
			local itemName = GetMerchantItemInfo( index );
			local reagentName = AutoBuyReagents_GetItemName( classTable[i] );
			
			if( itemName == reagentName ) then
				booleanReagentsTable[i] = true;
				merchantIndexes[i] = index;
			end
		end
	end
	
	return (booleanReagentsTable[1] or booleanReagentsTable[2] or booleanReagentsTable[3]);
end




function AutoBuyReagents_BuyReagents()


	for i = 1, # classTable do
		if( numReagentsTable[i] < tonumber(reagentTable[i]) ) then
			local checkBox = getglobal( "ReagentCheckButton" .. i );
			local numBuy = tonumber(reagentTable[i]) - numReagentsTable[i];
			
			if( checkBox:GetChecked() ) then
				AutoBuyReagents_Out( "ABR attempt to buy " .. numBuy .. " of " .. AutoBuyReagents_GetItemName( classTable[i] )  .. ". May have some missing of the max amount if Paladin or Hunter.");
				local maxBuy = 0;
				local countBy = 0;
					
				if( classTable[i] == 21177 ) then
					maxBuy = 1;
					countBy = 20;
				elseif( classTable[i] == 17033 ) then
					maxBuy = 5;
					countBy = 5;

				----- BEGIN added by jerryb1988
				elseif( classTable[i] == rHunter[1] ) then
					maxBuy = 1;
					countBy = 200;
				elseif( classTable[i] == rHunter[2] ) then
					maxBuy = 1;
					countBy = 200;
				----- END added by jerryb1988
				else
					maxBuy = 20;
					countBy = 20;
				end					
					
				while( numBuy >= countBy ) do
					BuyMerchantItem( merchantIndexes[i], maxBuy );
				 	numBuy = numBuy - countBy;
				end					
				
				if( numBuy < maxBuy and numBuy > 0 ) then
		 			BuyMerchantItem( merchantIndexes[i], numBuy );
		 		end
	 		end
		end
	end
end
AutoBuyReagents.xml also must be changed to allow more than 3 digits for hunter ammo. See next part 2.
Last edited by jerryb1988 : 11-08-09 at 10:41 PM.
jerryb1988 is offline Report comment to moderator  
Reply With Quote
Unread 04-13-09, 03:25 PM  
Shazear
A Fallenroot Satyr
 
Shazear's Avatar
AddOn Author - Click to view AddOns

Forum posts: 21
File comments: 15
Uploads: 3
Originally posted by aardvarkfarm
Is there any way to make this work with rogue poisons? For that matter, are more than 3 options even possible?
It's possible. I've pinged the author of this addon to see if he's still updating it or not. I've done the reagent research to figure out which poisons and such per level, just would need to update the XML and UI code to make it work.
__________________
Shazear:
Shizukana (Holy Priest)
UnShiz (UnHoly Death Knight)
Veterans of the Phoenix
Malygos
Shazear is offline Report comment to moderator  
Reply With Quote
Unread 04-08-09, 04:47 PM  
aardvarkfarm
A Kobold Labourer

Forum posts: 0
File comments: 1
Uploads: 0
Is there any way to make this work with rogue poisons? For that matter, are more than 3 options even possible?
aardvarkfarm is offline Report comment to moderator  
Reply With Quote
Unread 03-17-09, 07:07 PM  
Shazear
A Fallenroot Satyr
 
Shazear's Avatar
AddOn Author - Click to view AddOns

Forum posts: 21
File comments: 15
Uploads: 3
Death Knight fix.

To make ABR work for our DKs:
navigate to the addon folder: (C:\World of Warcraft\Interface\AddOns\AutoBuyReagents)

Open AutoBuyReagents.lua in notepad.

Replace line 2 & 3 with the following:
Code:
local indexTable = { "DEATHKNIGHT", "DRUID", "HUNTER", "MAGE", "PALADIN", "PRIEST", "ROGUE", "SHAMAN", "WARLOCK", "WARRIOR" }; 
local rDK = { 37201 };
The first entry in indexTable was "DEATH KNIGHT", so we're removing the space.
And the rDK value was nil, so replacing that with the item link value for Corpse Dust.

I was getting an error in a different part of the code that went away once this fix is made.
__________________
Shazear:
Shizukana (Holy Priest)
UnShiz (UnHoly Death Knight)
Veterans of the Phoenix
Malygos
Shazear is offline Report comment to moderator  
Reply With Quote
Unread 01-04-09, 11:03 AM  
Fragglerock
An Aku'mai Servant

Forum posts: 32
File comments: 73
Uploads: 0
Could you possibly add corpse dust for Dk's ? Thanks!!
Fragglerock is offline Report comment to moderator  
Reply With Quote
Unread 12-11-08, 11:31 AM  
eraser2011
A Kobold Labourer

Forum posts: 0
File comments: 4
Uploads: 0
now it looks like this:



p.s. the error message is away
eraser2011 is offline Report comment to moderator  
Reply With Quote
Unread 12-11-08, 10:40 AM  
tsukeru
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 16
Uploads: 2
Originally posted by eraser2011
Sry i forgot to say that ever wenn i log in i get this error message


Date: 2008-12-11 16:22:09
ID: 1
Error occured in: Global
Count: 1
Message: ..\AddOns\AutoBuyReagents\AutoBuyReagents.lua line 130:
attempt to concatenate local 'rank2' (a nil value)
Debug:
(tail call): ?
[C]: ?
AutoBuyReagents\AutoBuyReagents.lua:130: AutoBuyReagents_DruidReagents()
AutoBuyReagents\AutoBuyReagents.lua:40: AutoBuyReagents_OnEvent()
[string "*:OnEvent"]:1:
[string "*:OnEvent"]:1
Maybe, just maybe. This latest version will work for you. I removed that line of code that executed to give you that error. It was simple debugging printout that shouldn't of been there anyhow. Let me know how it goes this time.
tsukeru is offline Report comment to moderator  
Reply With Quote
Unread 12-11-08, 09:39 AM  
eraser2011
A Kobold Labourer

Forum posts: 0
File comments: 4
Uploads: 0
Sry i forgot to say that ever wenn i log in i get this error message


Date: 2008-12-11 16:22:09
ID: 1
Error occured in: Global
Count: 1
Message: ..\AddOns\AutoBuyReagents\AutoBuyReagents.lua line 130:
attempt to concatenate local 'rank2' (a nil value)
Debug:
(tail call): ?
[C]: ?
AutoBuyReagents\AutoBuyReagents.lua:130: AutoBuyReagents_DruidReagents()
AutoBuyReagents\AutoBuyReagents.lua:40: AutoBuyReagents_OnEvent()
[string "*:OnEvent"]:1:
[string "*:OnEvent"]:1
eraser2011 is offline Report comment to moderator  
Reply With Quote
Unread 12-11-08, 02:22 AM  
tsukeru
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 16
Uploads: 2
Originally posted by eraser2011
Thank you for the much work! But there are still problems
I post a screenshot
Ahh, but it really works on mine this time. This is crap! lol I'm not sure why it's not working for you. Try a reload ui and see if that'll fix it up. Also, at the beginning of your chat window at startup/reload ui you'll see some white letter like "Rank x Rank x" followed by a number. Look for them at the top and tell me what they are.
Last edited by tsukeru : 12-11-08 at 02:23 AM.
tsukeru is offline Report comment to moderator  
Reply With Quote
Unread 12-11-08, 01:53 AM  
eraser2011
A Kobold Labourer

Forum posts: 0
File comments: 4
Uploads: 0
Thank you for the much work! But there are still problems
I post a screenshot
eraser2011 is offline Report comment to moderator  
Reply With Quote
Unread 12-10-08, 04:16 PM  
tsukeru
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 16
Uploads: 2
Originally posted by eraser2011
The problems are not solved for my druid
So sorry! Try the latest one now, I went back and made sure it was working.
tsukeru is offline Report comment to moderator  
Reply With Quote
Unread 12-10-08, 03:03 PM  
eraser2011
A Kobold Labourer

Forum posts: 0
File comments: 4
Uploads: 0
The problems are not solved for my druid
eraser2011 is offline Report comment to moderator  
Reply With Quote
Unread 12-10-08, 01:36 PM  
tsukeru
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 16
Uploads: 2
Druid and Priest fixes

I believe the latest update should fix all druid and priest errors. It fixed druid errors in my limited play test (didn't test thoroughly) and I think it should fix priest errors. Update and let me know if the errors persist. Thank you for your support!
tsukeru is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: