SRL Archive - OSR Help

ChooseOption not working


risingtide13

2013-04-20 19:57:18

ChooseOption() Was working fine for the past few days as I was working on the script, I don't remember making any changes to the code but maybe I did. Basically I need to right-click and choose deposit all. Some fixes I have tried are using an if… then statement involving the color of item and uptext, and checking if bank screen is open. I just extracted the part of the script not working:


program ChooseOption;

{$i SRL/srl.simba}

begin
SetupSRL;
MMouse(267, 129, 3, 3);
Wait(1500);
Clickmouse2(mouse_right);
wait(1500);
ChooseOption('osit-All');
end.

Chris!

2013-04-20 20:03:58

Why don't you try SRL's DepositAll; procedure?

(*
DepositAll
~~~~~~~~~~

.. code-block:: pascal

function DepositAll: Boolean;

Deposits all items in your inventory.

.. note::

Author: Shuttleu
Last Modified: January 08, 2012 by Coh3n

Example:

.. code-block:: pascal

DepositAll();
*)
function DepositAll: Boolean;
begin
if (InvEmpty) then
begin
Result := True;
Exit;
end;

QuickDeposit(SRL_DEPOSIT_ALL);
Result := WaitFunc(@InvEmpty, 50, 3000);
end;

risingtide13

2013-04-20 20:13:28

I'm not depositing all, i'm depositing all of a certain item but not my entire inventory. I have also tried

Deposit(SlotFrom, SlotTo: Integer; vType: Variant)


This procedure only works if I want to deposit each one by one. When I use Deposit() to deposit all, it only right clicks on the item, but does not choose all, as mentioned in my original post.

Chris!

2013-04-20 20:20:04

This is one of my banking procedures for my willow chopper:

procedure DepositStuff;
begin
if BankScreen then
begin
repeat
if not (LoggedIn) then
LoginPlayer;
if (ExistsItem(28) or (InvCount > 1)) then
begin
if Skiller then
DepositOther(2, 28, True) //I placed DepositOther (from bud_wis_er) at the top of my script so people don't have to update there banking.simba file to run the script.
else
DepositAll;
Wait(RandomRange(500, 75));
Writeln('Depositing inventory.')
end;
until (InvCount = 1) or (InvCount = 0)
end;
Inc(Loads);
if Random(2) = 1 then
CloseBank;
end;

Here is DepositOther:

procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant);
var
DepositX, BScreen, DScreen, f: Boolean;
All: Variant;
I, T, x, y, c, j: Integer;
B: TBox;
Options: array of TOptions;
begin
BScreen := BankScreen;
if (not(BScreen)) then
DScreen := DepositScreen;
if not (BScreen or DScreen) then
Exit;
if vType = 2 then
srl_Warn('Deposit', '2 now means store per 2, not ''All''', 15);
DepositX := False;
if VariantIsInteger(vType) then
begin
DepositX := not InIntArray([1, 5, 10], vType);
All := vType <> 1;
end
else if VariantIsBoolean(vType) then
All := vType;
if (SlotFrom = 1) and (SlotTo = 28) and (All = true) then
if DepositAll then
exit;
for I := SlotFrom to SlotTo do
begin
if (BScreen) then
begin
If Not ExistsItem(I) Then
Continue;
if (not All) then
MouseItem(I, mouse_left)
else
MouseItem(I, mouse_right);
end else
begin
B := DepositItemBox(I);
if (not(FindColor(X, Y, srl_outline_black, B.X1, B.Y1, B.X2, B.Y2))) then
Continue;
if (not All) then
Mouse((B.X1 + B.X2) shr 1, (B.Y1 + B.Y2) shr 1, 0, 0, mouse_left)
else
Mouse((B.X1 + B.X2) shr 1, (B.Y1 + B.Y2) shr 1, 0, 0, mouse_right);
end;
if DepositX then
begin
WaitOptionMulti(['Deposit-X', 'Deposit'], 200);
T := GetSystemTime;
while (not FindColor(x, y, 8388608, MCX1, MCY1, MCX2, MCY2)) and (GetSystemTime - T < 3000) do
Wait(100);
TypeSend(vType);
end else if VariantIsInteger(vType) then
WaitOptionMulti(['Deposit-' + IntToStr(Integer(vType)), 'Deposit'], 200)
else
begin
// Starting my code
wait(2000);
Options := GetChooseOptions('All');
if (Length(Options) < 1) then
Break;
c := High(Options); ;
f := False;
for j := 0 To c do
begin
if ArrInStr(['All'], Options[j].Str) then
begin
writeln('Option all found, clicking');
ChooseOptionMulti(['Deposit-All', 'All']);
f := True;
Break;
end;
end;
if (f = False) then
ChooseOptionMulti(['Depo' , 'osit']);
end;
// Ending my code
T := GetSystemTime;
Wait(RandomRange(200, 300));
repeat
if (BScreen) then
if (not(ExistsItem(I))) then Break;
if (DScreen) then
if (not(FindColor(X, Y, srl_outline_black, B.X1, B.Y1, B.X2, B.Y2))) then Break;
Wait(50);
until(GetSystemTime - T > 2000);
end;
end;

You can find the post about it here: http://villavu.com/forum/project.php?issueid=50

King

2013-04-20 20:27:31

From: Chris!
This is one of my banking procedures for my willow chopper:

procedure DepositStuff;
begin
if BankScreen then
begin
repeat
if not (LoggedIn) then
LoginPlayer;
if (ExistsItem(28) or (InvCount > 1)) then
begin
if Skiller then
DepositOther(2, 28, True) //I placed DepositOther (from bud_wis_er) at the top of my script so people don't have to update there banking.simba file to run the script.
else
DepositAll;
Wait(RandomRange(500, 75));
Writeln('Depositing inventory.')
end;
until (InvCount = 1) or (InvCount = 0)
end;
Inc(Loads);
if Random(2) = 1 then
CloseBank;
end;

Here is DepositOther:

procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant);
var
DepositX, BScreen, DScreen, f: Boolean;
All: Variant;
I, T, x, y, c, j: Integer;
B: TBox;
Options: array of TOptions;
begin
BScreen := BankScreen;
if (not(BScreen)) then
DScreen := DepositScreen;
if not (BScreen or DScreen) then
Exit;
if vType = 2 then
srl_Warn('Deposit', '2 now means store per 2, not ''All''', 15);
DepositX := False;
if VariantIsInteger(vType) then
begin
DepositX := not InIntArray([1, 5, 10], vType);
All := vType <> 1;
end
else if VariantIsBoolean(vType) then
All := vType;
if (SlotFrom = 1) and (SlotTo = 28) and (All = true) then
if DepositAll then
exit;
for I := SlotFrom to SlotTo do
begin
if (BScreen) then
begin
If Not ExistsItem(I) Then
Continue;
if (not All) then
MouseItem(I, mouse_left)
else
MouseItem(I, mouse_right);
end else
begin
B := DepositItemBox(I);
if (not(FindColor(X, Y, srl_outline_black, B.X1, B.Y1, B.X2, B.Y2))) then
Continue;
if (not All) then
Mouse((B.X1 + B.X2) shr 1, (B.Y1 + B.Y2) shr 1, 0, 0, mouse_left)
else
Mouse((B.X1 + B.X2) shr 1, (B.Y1 + B.Y2) shr 1, 0, 0, mouse_right);
end;
if DepositX then
begin
WaitOptionMulti(['Deposit-X', 'Deposit'], 200);
T := GetSystemTime;
while (not FindColor(x, y, 8388608, MCX1, MCY1, MCX2, MCY2)) and (GetSystemTime - T < 3000) do
Wait(100);
TypeSend(vType);
end else if VariantIsInteger(vType) then
WaitOptionMulti(['Deposit-' + IntToStr(Integer(vType)), 'Deposit'], 200)
else
begin
// Starting my code
wait(2000);
Options := GetChooseOptions('All');
if (Length(Options) < 1) then
Break;
c := High(Options); ;
f := False;
for j := 0 To c do
begin
if ArrInStr(['All'], Options[j].Str) then
begin
writeln('Option all found, clicking');
ChooseOptionMulti(['Deposit-All', 'All']);
f := True;
Break;
end;
end;
if (f = False) then
ChooseOptionMulti(['Depo' , 'osit']);
end;
// Ending my code
T := GetSystemTime;
Wait(RandomRange(200, 300));
repeat
if (BScreen) then
if (not(ExistsItem(I))) then Break;
if (DScreen) then
if (not(FindColor(X, Y, srl_outline_black, B.X1, B.Y1, B.X2, B.Y2))) then Break;
Wait(50);
until(GetSystemTime - T > 2000);
end;
end;

You can find the post about it here: http://villavu.com/forum/project.php?issueid=50


:ninja: 'd me to it chris :P

risingtide13

2013-04-20 20:31:56

Looked into it and tried bud_wis_er's function, same problem… it opens up the ChooseOptions menu but doesn't end up clicking all. Three different functions and same result, could it be that it isn't recognizing the font or something like that?

Chris!

2013-04-20 20:34:15

If your script is for OSR (2007), then you need to install the 07 fonts! You can find them here: http://villavu.com/forum/showthread.php?t=99992 down in the Quick Guide on OSR installation section.

If your script is for EoC - I have no idea. :(

risingtide13

2013-04-20 20:35:37

It's for EoC, meh getting frustrated I'll take a look at it later. Thanks though Chris!

King

2013-04-20 20:38:08

From: risingtide13
It's for EoC, meh getting frustrated I'll take a look at it later. Thanks though Chris!



Did you change the CTS in your script?

Try calling a procedure like this

Writeln(getuptext);


To see the uptext, also make sure you reset your CTS settings to normal.

risingtide13

2013-04-20 22:37:41

Issue was resolved kinda, sorta… it works if I run it through SMART, but not if i run it on a webpage, which really isn't that big of a deal.

Thanks for the help.

t4q

2013-04-21 12:02:30

You can try:
WaitOption('option',1000);