SRL Archive - Research & Development Lounge

Various Functions


sirlaughsalot

2009-02-16 11:59:30

These are just some functions I have made over my career.

Color

General


{*******************************************************************************
Function EnterAmount: Boolean;
By: Sirlaughsalot
Description: Checks for EnterAmount in the chat box
*******************************************************************************}
Function EnterAmount: Boolean;
begin
Result := FindTextTPA(0,0,MCx1,Mcy1,MCx2,MCy2, 'nter', UpChars, Nothing);
end;

Reflection

Banking
{*******************************************************************************
Procedure R_DepositAllExcept(What:Integer);
By: Sirlaughsalot
Description: Deposits everything expcept the specified ID
*******************************************************************************}
Procedure R_DepositAllExcept(What:Integer);
var
huh : Tpoint;
Item: TInvItem;
begin
For i:=0 to 28 do
begin
Item:=GetInvItemInfo(i);
if (Item.ID<>What) and (Item.ID>0) then
begin
Huh:=ItemCoords(i);
Mouse(huh.x,huh.y,5,5,False);
Wait(400+random(300));
ChooseOption('ll');
end;
end;
end;

{*******************************************************************************
Procedure IsInBank(What: TBankSlot; var WhatSlot : Integer) : Boolean;
By: Sirlaughsalot
Description: Checks if an item is in the bank and returns the slot
*******************************************************************************}
Function IsInBank(What : TBankSlot; var WhatSlot : Integer) : Boolean;
Var
I : integer;
BankAr : TBankSlotArray;
begin
if not R_BankScreen then exit;
BankAr:=GetBankArray;
For i:=0 to High(BankAr) do
begin
if (BankAr[i].ID=What.ID) or (BankAr[i].Name=What.Name) then Result:=True;
WhatSlot:=BankAr[i].Index;
Writeln(IntToStr(WhatSlot));
if Result then Exit;
end;
end;

{*******************************************************************************
Procedure R_SearchBank(WhatFor: Integer; var ItemName : String) : Boolean;
By: Sirlaughsalot
Description: Searches the bank for the item with the specified ID and returns
the name
*******************************************************************************}
Function R_SearchBank(WhatFor : Integer; var ItemName : String) : Boolean;
var
Ind : Integer;
Item : TBankSlot;
begin
if BankScreen then
begin
Item.ID:=WhatFor;
if IsInBank(Item, Ind) then
begin
Writeln(IntToStr(Ind));
Item:=GetBankSlot(Ind)
ItemName:=Item.Name;
Writeln(Item.Name);
SearchBank(Item.Name);
Result:=True;
Writeln(BoolToStr(Result));
end;
end;
end;

{*******************************************************************************
Procedure WithdrawItem(What: Integer; Option, IfX : String) : Boolean;
By: Sirlaughsalot
Description: Tries to withdraw the specified item via ID, Option is for
ChooseOption, IfX is how many to withdraw if Option is X
*******************************************************************************}
Function WithdrawItem(What : Integer; Option, IfX : String) : Boolean;
var
x, y, i : integer;
Slot : TBox;
Name : String;
Invent : TIntegerArray;
begin
if R_SearchBank(What, Name) then
begin
For i:=1 to 50 do
begin
Slot:=BankIndexToMSBox(i);
MouseBox(Slot.x1,Slot.y1,Slot.x2,Slot.y2,3);
GetMousePos(x,y);
Delete(Name,1,1);
Wait(200+random(200));
if IsUpText(Name) then
begin
Mouse(x,y,0,0,False);
ChooseOption(Option);
if LowerCase(Option)='x' then
begin
Wait(500+Random(400));//Edit later
if FindTextTPA(0,0,MCx1,Mcy1,MCx2,MCy2, 'nter', UpChars, Nothing) then
TypeSend(IfX);
end;
Wait(500+random(500));
end;
if (InventoryContains(What+1, Invent)) or (InventoryContains(What+2, Invent)) then
begin
Result:=True
exit;
end;
end;
end;
end;

Floor66

2009-02-18 14:29:05

For the amount function:

Function FillIn: Boolean;
Begin
Result := (GetColor(260, 428) = 8388608);
End;

Finds the blue "*" to fill something in.

sirlaughsalot

2009-02-18 18:23:07

From: Floor66
For the amount function:

Function FillIn: Boolean;
Begin
Result := (GetColor(260, 428) = 8388608);
End;

Finds the blue "*" to fill something in.


That works too :)

Da 0wner

2009-02-18 20:19:43

But will not work when something is entered ;). Although you would already know it is there…Just a heads up. SirLaughsAlot's will work regardless, but is a little slower.

Floor66

2009-02-19 11:17:16

Well.. I guess the situation 'when something is already entered' is not possible.. you'd need to check for IF it's open BEFORE you enter something..

Da 0wner

2009-02-19 11:57:00

Yeah, that's what I meant so his would work, but I use a method similar to yours to be sure :0.