SRL Archive - Help

If certain object is on inventory, and if not, withdraw from bank


onilika

2011-08-01 13:59:12

How do I set this for "Thread" and "Needle"? (Is this form for many objects, or just one object?)

function R_ItemExists(TheVar: Variant; var Item: TInvItem): Boolean;
var
Items: TInvItemArray;
begin
Result := R_ItemExistsEx([TheVar], Items);
if Result then
Item := Items[0];
end;

If not in inventory, how do I set to withdraw from bank?

function R_WithdrawItemsEx(TheVarArr: TVariantArray; All: Boolean): Boolean;
var
Items: TBankItemArray;
TempItem: TBankItem;
Item: TInterfaceComponent;
I, X, Y, Inv, T: Integer;
begin
Result := False;
if not R_BankScreen then
Exit;
if not R_ItemsExistInBankEx(TheVarArr, Items)then
begin
R_Debug('Items not found in bank.', 'R_WithdrawItemsEx');
Exit;
end;

Result := True;
for I := 0 to High(Items) do
begin
if not R_ItemExistsInBank(Items.Name, TempItem)then
begin
Result := False;
R_Debug('Unable to find '+Items.Name, 'R_WithdrawItemsEx');
Continue;
end;
if not R_ScrollToIndex(TempItem.Slot) then
begin
Result := False;
R_Debug('Unable to scroll to '+Items.Name, 'R_WithdrawItemsEx');
Continue;
end;
Item := R_GetInterfaceComponent(INTERFACE_BANK, INTERFACE_BANK_SLOTS, TempItem.Slot);
R_ClickInterface(Item, 3);
GetMousePos(X, Y);
Inv := R_InvCount;

case All of
True: begin
Mouse(x, y, 0, 0, false);
if(not R_WaitOption('Withdraw-All', 2000))then
begin
R_Debug('Unable to withdraw '+Item.Name, 'R_WithdrawItemsEx');
Result := False;
Continue;
end;
end;
False: Mouse(x, y, 0, 0, true);
end;

MarkTime(T);
while (R_InvCount = Inv)do
begin
if(TimeFromMark(T) > 5000)then
begin
R_Debug('Unable to withdraw '+Item.Name, 'R_WithdrawItemsEx');
Result := False;
Break;
end;
Wait(50+Random(50));
end;

Wait(500+Random(1000));
//Need to give the bank interface time to reload if an item was removed.
end;
end;

Smarter Child

2011-08-01 14:11:29

Um not sure what you want, i'll write example here:

 Function sameple: boolean;
var
ThreadObj: TInvItem;
StartInv: integer;
begin
R_OpenBankBooth;
if BankScreen then
begin
if not R_ItemExists('Thread', ThreadObj)then
begin
StartInv := ThreadObj.StackSize;
R_WithdrawX('Thread', 1);
Wait(200 + Random(500));
if ThreadObj.StackSize > StartInv then
begin
Writeln('Withdrew 1 thread!');
Result := true;
end;
end;
end;
end;

There are also other functions like:

R_WithdrawAllButOne('Thread');
R_WithdrawItem('Thread', true); //true = Withdraw All

So there is no real need for interfaces and stuff like R_WaitOption('Withdraw-All', 2000))

Not to mention, that the Reflection withdrawal functions will scroll down the bank screen for the object ;)

onilika

2011-08-01 14:26:17

From: Smarter Child
Um not sure what you want, i'll write example here:

 Function sameple: boolean;
var
ThreadObj: TInvItem;
StartInv: integer;
begin
R_OpenBankBooth;
if BankScreen then
begin
if not R_ItemExists('Thread', ThreadObj)then
begin
StartInv := ThreadObj.StackSize;
R_WithdrawX('Thread', 1);
Wait(200 + Random(500));
if ThreadObj.StackSize > StartInv then
begin
Writeln('Withdrew 1 thread!');
Result := true;
end;
end;
end;
end;

There are also other functions like:

R_WithdrawAllButOne('Thread');
R_WithdrawItem('Thread', true); //true = Withdraw All

So there is no real need for interfaces and stuff like R_WaitOption('Withdraw-All', 2000))

Not to mention, that the Reflection withdrawal functions will scroll down the bank screen for the object ;)



Smarter Child, what I ment to say was: In case that no thread n'or needle is found at the inventory, to withdraw from bank.

Smarter Child

2011-08-01 14:32:01

if not R_ItemExists('Thread', ThreadObj)then //This checks the inventory interface

R_ItemExists returns whether or not the the Item Exists in the inventory, 'Thread' is the name of the object, so you could do an R_ItemExists check for both the needle and thread ?

onilika

2011-08-01 14:35:35

OK..Thanks Smarter Child! :)