SRL Archive - SRL Bugs

WithdrawEx


riwu

2012-06-17 03:27:57

 if (WaitOptionMultiEx(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)], 'All', Nothing, 300)) then
Result := ChooseOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)]);
If the option before Withdraw-X is a non-single digit number, say 22, and u intend to withdraw 2, it will withdraw 22 instead as it doesn't check beyond "w-2".
Possible fix would be to check that the text after the (Amount) is blank, or 2 space after it is an orange text.

YoHoJo

2012-06-17 03:31:37

So you are saying.
If before withdraw X you have withdraw 22 (from previous play)
And then you use withdraw X to withdraw 2, it will pick the 22?

Yeah that makes sense. Good catch.
Bet it rarely happens though, but good :D

Ezio Auditore da Firenze

2012-06-17 03:35:03

From: YoHoJo
So you are saying.
If before withdraw X you have withdraw 22 (from previous play)
And then you use withdraw X to withdraw 2, it will pick the 22?

Yeah that makes sense. Good catch.
Bet it rarely happens though, but good :D


Exactly what he's saying. Hmm no its quite a common problem :/

YoHoJo

2012-06-17 03:36:08

Just change your last withdraw X to something else to fix it?

Ezio Auditore da Firenze

2012-06-17 03:41:05

Guess I'll have to do that, always take the easy way out.

riwu

2012-06-17 04:54:02

Yeah its a rather common problem:
From: Jonno
Oh no not physically, its just that Withdraw "x" which is 20 prayer pots is the last value taken out and when the script finishes its round that "x" becomes 20 and so it takes out 20 pouches ^.^


This is what i do in my DomDag script to reset the X option to single digit:
   
MouseBankSlot(1,mouse_Right);
InvItems:=InvCount;
if WaitOptionMulti(['Withdraw-X', 'w-X'], 1500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do //Ripped from include
Wait(50);
HumanWait(20,110,340);
TypeSend(IntToStr(RandomRange(2,4)));
MarkTime(InvWait);
repeat
wait(RandomRange(60,220));
until (InvCount>InvItems) or (TimeFromMark(InvWait)>3000);
And i just realize that i'll have to do this every time before withdrawing any item since their bank settings may be to withdraw >10 items for the previous item. (Or i can check and only do this if the previous withdraw quantity is indeed >10), or a better solution would be to edit the include such that it always use X to withdraw any amount that is not 1,5,10.


Nevertheless i think the problem should still be fixed as other scripters may not be aware of the issue and hence unknowingly inducing error in their scripts.

YoHoJo

2012-06-17 05:14:09

You could do.

Right Click Item
If not WaitOption('w 2 ', 1000) Then //NOTICE THE SPACE AFTER THE TWO, THAT WILL STOP FROM PICKING 22
Begin
WaitOption('X', 1000);
TypeSend('2');
End;

^Not 100% real code, but you get it ya?

Olly

2012-06-17 10:29:41

Happens to me alot, I just set my withdraw x to something different.

Brandon

2012-06-17 11:35:30

Had this problem before.. The actual fix is:

'Withdraw-' + IntToStr(Amount) + ' '

The space after is required. When the OCR looks for the options, it will look for 2 space nothing. If you put 22, it will look for 22 space nothing. The difference will be the space so that it does knows the difference between 2 and 22.

Example:
Its the difference between Pos(….) or PosEx(….) to find the position of a value in a string. This can cause problems if that value isn't a unique/single value. This is why Regex's are supposed to be used (ExecRegExpr) but since no one is going to re-write it, just put the space to distinguish singularity.

Choose Options still uses Pos -_-

putonajonny

2012-06-17 11:51:57

Proposed Changes:
(*
WithdrawEx
~~~~~~~~~~

.. code-block:: pascal

function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;

Withdraws Amount at Column/Row.

.. note::

Author: Starblaster100, Town, Wizzup? and Narcle, small fixes by r!ch!e & EvilChicken!
Last Modified: Unknown

Example:

.. code-block:: pascal

WithdrawEx(1, 3, 28, ['ron ore', 'ore', 'on or']);
*)
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin

Result := False;

if(Amount < -1)then
begin
srl_Warn('WithdrawEx', 'Invalid Selection for amount: '+IntToStr(Amount), warn_AllVersions);
exit;
end;

FixBank;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_move);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500+Random(200))) then
Exit;

Case Amount of
-1 : begin
ClickMouse2(mouse_Right);
if (WaitOptionMultiEx(['Withdraw-All but', 'l b'], 'All', Nothing, 300+Random(200))) then
Result := ChooseOptionMulti(['Withdraw-All but', 'l b']);
exit;
end;
0 : begin
ClickMouse2(mouse_Right);
if (WaitOptionMultiEx(['Withdraw-All', 'w-A'], 'All', Nothing, 300+Random(200))) then
Result := ChooseOptionMulti(['Withdraw-All', 'w-A']);
exit;
end;
1 : begin
ClickMouse2(mouse_Left);
Result := True;
Wait(RandomRange(250, 550));
exit;
end;
end;

ClickMouse2(mouse_Right);

if (WaitOptionMultiEx(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)], 'All', Nothing, 300+Random(200))) then
begin
Result := ChooseOptionMulti(['Withdraw-' + IntToStr(Amount)+' ', 'w-' + IntToStr(Amount)+' ']);
exit;
end;

if (Amount > 1) then
begin
if (not OptionsExist(['Withdraw', 'ithdraw', 'draw'], nothing)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, mouse_right);

if WaitOptionMulti(['Withdraw-X', 'w-X'], 500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(Random(50));
Wait(RandomRange(75, 400));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;
I got rid of a lot of the ifs and put in a case statement to neaten things up…

Brandon

2012-06-17 12:02:36

A simple change to ChooseOptions will suffice:

Instead of doing Pos or PosEx just do ExecRegExpr(PreferredOption, ListOfOptionsFound);

That's it. If this happens to any other functions, they will automatically be fixed rather than changing every single one specifically to have a space.