SRL Archive - SRL Snippets

WithdrawItemExMulti


Silent

2012-02-21 14:23:17

I'm sure there is a simpler solution, but here it is. Multi stands for the multi-uptext that it can handle… This was really bothering me so I modified WithdrawItemEx to build it. Not really that many significant changes.

function WithdrawItemExMulti(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): Boolean;
var
x, y, i: integer;
BPoint: TPoint;
BankBox: TBox;
Found: Boolean;
t: TPointArray;
label
Start;
begin
Result := False;
if not BankScreen then Exit;
FixBank;

if (Index = 0) then
begin
Start:
for Index := 1 to 50 do
begin
if FindItemEx(x, y, IdentType, Ident, BankIndexToMSBox(Index), Tol) then
begin
MMouse(x, y, 4, 4);
if WaitUpTextMulti(UpText, 300) then
begin
Writeln('Found Item at Bank Slot ' + IntToStr(Index) + '.');
Found := True;
Break;
end else
Writeln('Found Incorrect Item, Moving to new Bank Spot.');
end;
end;
end else
begin
BankBox := BankIndexToMSBox(Index);
FindColors(t, srl_outline_black, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
BankBox := GetTPABounds(t);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, mouse_move);
if WaitUpTextMulti(UpText, 300) then
Found := true
else
begin
Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
GoTo Start;
end;
end;
Wait(RandomRange(200, 350));
if Found then
begin
BPoint := BankIndexToBankPoint(Index);
//Writeln(IntToStr(BPoint.x) + ', ' + IntToStr(BPoint.y));
Withdraw(BPoint.x, BPoint.y, Amount);
Result := True;
end else
begin
Index := 0;
for i:=1 to Length(UpText) do
begin
SRL_Warn('WithdrawItem', 'Could not Find ' + IdentType + ' in Bank. [Uptext: ' + UpText[i] + ']', Warn_AllVersions);
end;
end;
end;

putonajonny

2012-02-26 07:39:06

I like this, if this is added WithdrawItemEx should be changed to:

function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: string; Tol: TIntegerArray): Boolean;
begin
Result := WithdrawItemExMulti(Ident, IdentType, Index, Amount, [UpText], Tol); Boolean
end;

and I'd suggest calling it WithdrawItemMultiEx not WithdrawItemExMulti

Coh3n

2012-02-26 16:08:30

WithdrawItemMultiEx seems like it should withdraw multiple items, not just have multiple uptexts.

putonajonny

2012-02-27 11:07:14

From: Coh3n
WithdrawItemMultiEx seems like it should withdraw multiple items, not just have multiple uptexts.


Well I think that the normal WithdrawItemEx should support multiple up texts, there is no reason for it not to, then have:

function WithdrawMultiItemEx(Idents: TintegerArray; IdentTypes: TstringArray; var Indexs: TintegerArray; Amounts: TintegerArray; UpTexts: array of TstringArray; Tol: TIntegerArray): Boolean;
Var
i : integer;
begin
for i := 0 to high(Indents) do
Result := Result and WithdrawItemEx(Ident[i], IdentType[i], Index[i], Amount[i], UpText[i], Tol);
end;

Coh3n

2012-02-27 13:21:43

I agree, except that changing a parameter like that will cause whatever script using that function to break.