SRL Archive - SRL Archives

function ChooseOptionWithBad


grindisbest

2007-05-26 04:19:27

Here's a function I use in one of my scripts. Its much like Stupid3000s ChooseOption with a little extra. Read the comment in the script.

function ChooseOptionWithBad(x, y: Integer; bad, txt: string): Boolean;
{
By Grindisbest, Credit to Stupid3000.
Thanks to Stupid3000, I've just edited it. Its much like the ChooseOption function expect it will
only choose option if the option it looks at doesn't contain a string (bad)
in it.
Example. You search for 'Trade' as the option and put 'with' as the bad string,
it will click on the first option that has 'Trade' in it as long as it doesn't
have 'with' in it, otherwise it will search on. If it doesn't find one it will
click Cancel.
}
var
a, b, x1, y1, x2, y2, FinalX, FinalY, LeftCorner, RightCorner: Integer;
Found: Boolean;
begin
LeftCorner := BitmapFromString(4, 4, 'z78DA33753135313137C5' +
'411A600064715CEA914500CACE13F0');
RightCorner := BitmapFromString(4, 4, 'z78DA33753135313137' +
'C5200D30002E35F8C501C9C013F0');
Found := False
if (FindBitmap(LeftCorner, x1, y1)) and (FindBitmap(RightCorner, x2, y2)) then
begin
repeat
if FindText(FinalX, FinalY, txt, upchars, x1, y1, x2, 502) and not FindText(a, b, bad, upchars, x1, FinalY, x2, FinalY+20) then
begin
Found := True;
end else
begin
y1:=y+10;
Found := False;
end;
until((not FindText(x, y, txt, upchars, x1, y1, x2, 502)) or Found);
if (FindText(x, y, 'Cancel', upchars, x1, y1, x2, 502)) and (not Found) then
Mouse(x + 9, y + 3, 2, 2, True);
if Found then
begin
Result := True;
Mouse(FinalX + Length(txt) * 3, FinalY + 3 + Random(3), 2, 2, True);
end;
end;
FreeBitmap(LeftCorner);
FreeBitmap(RightCorner);
end;


So what do you think?

bullzeye95

2007-05-26 08:37:51

Nice, this is needed in SRL. Good job :)

WT-Fakawi

2007-05-26 16:12:31

I had a similar problem setting priorities for ChooseOption for my CowKiller/HideBanker. I wanted to always pickup Hides first. I came up with this:

{*******************************************************************************
function ChooseOption3: Boolean;
By: Stupid3ooo modded by WT-Fakawi
Description: Finds Popup menu, then clicks on Hides, Bones, Meat in that order.
*******************************************************************************}

Function ChooseOption3:Boolean;
var
x1, y1, x2, y2, LeftCorner, RightCorner, Fx, Fy, BitMap, I: Integer;
begin
LeftCorner := BitmapFromString(4, 4, 'z78DA33753135313137C5' +
'411A600064715CEA914500CACE13F0');
RightCorner := BitmapFromString(4, 4, 'z78DA33753135313137' +
'C5200D30002E35F8C501C9C013F0');
if (FindBitmap(LeftCorner, x1, y1)) and (FindBitmap(RightCorner, x2, y2)) then
begin
for I := 1 to 3 do // ALWAYS COWHIDE FIRST!!! :)
begin
if CollectMeat then
begin
case I of
1: BitMap := CowHideText; // Sliced Bitmaps of MenuItemText
2: BitMap := RawBeefText; // Works like a charm
3: BitMap := BonesText;
end;
end
else
begin
case I of
1: BitMap := CowHideText; // Sliced Bitmaps of MenuItemText
2: BitMap := BonesText; // Works like a charm
3: BitMap := RawBeefText;
end;
end

If FindBitMap(BitMap, Fx, Fy) then
begin
Mouse(Fx, Fy, 20, 4, True);
Result := True;
FlagFTWait;
Exit;
end;
end;
if (FindText(Fx, Fy, 'Cancel', upchars, x1, y1, x2, 502)) then
Mouse(Fx + 9, Fy + 3, 2, 2, True);
end;
FreeBitmap(LeftCorner);
FreeBitmap(RightCorner);
end;


EDIT: These are the bitmaps:


  CowHideText := BitmapFromString(25, 1, 'z78DA7373B334303170' +
'03931060EA626A6262EE4684387E9254D390C5019A022059');

BonesText := BitmapFromString(24, 1, 'z78DA7373B33430317003' +
'931060EA626A6262EE4603714C121940D40300C5511EC7');

RawBeefText := BitmapFromString(29, 1, 'z78DA7373B334303170' +
'0393C8C00D43DCD4C5D4C4C41C591C3F89AC0B17498C2DC8E200C' +
'CC02560');

Bobarkinator

2007-05-26 22:06:31

I needed this when making my eye of newt buyer for the exact reason you pointed out.

grindisbest

2007-05-26 23:14:29

Yup, my eye of newt buyer is the reason I made it! :D

Bobarkinator

2007-05-27 13:43:58

Tarajunky gave me a function that clicked any color of text so I could have it click (Trade Betty)