Tim0suprem0
2010-06-15 17:07:10
Hi guys,
When the Optionbox is as big as the screen (top to bottom), I get
Here is ChooseOptionMultiEx (where the problem is)
The error on line 558 is SortATPAFromFirstPoint(ATPA, Point(OptionBox.X1, optionbox.y1)), but the problem is that when the optionbox is that big,
splits the colors on each side of the optionbox into to two TPA's, and then only uses the one on the left side (atpa[0]) for the TBox of where to look for the text.
So FindColorsTolerance(aTPA, Colors[SearchCols], B.X1, B.Y1, B.X2, B.Y2, 3) is basically just looking at a vertical line, because B.X1 and B.X2 are equal.
That means that aTPA doesn't get filled with any of the text color it's looking for, so when SortATPAFromFirstPoint gets called, it gets passed an empty ATPA and then it's out of range when it tries to sort the TPAs.
My question is, why split it up in the first place? I'm pretty sure using
When the Optionbox is as big as the screen (top to bottom), I get
[Runtime Error] : Exception: Access violation at address 041AAE36 in module 'WizzyPlugin.dll'. Read of address 00000000 in line 558 in script C:\Program Files\SCAR 3.23 Beta\includes\SRL\SRL\Core\Text.scar which is super annoying when my players are on a busy world and trying to find the fishing spot because it instantly kills the script.Here is ChooseOptionMultiEx (where the problem is)
{*******************************************************************************
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
By: Wizzup?, Nava2, and N1ke!
Description: Finds Popup menu, then clicks on it.
Will look for the first string first and so on.
It will search for the Text Type you input valid arguments are
'action', 'player': The white text
'npc': The yellow text
'object': The cyan text
'all': Searches for all colors of text.
Will default to 'all'.
*******************************************************************************}
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
var
B,OptionBox: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, H, HH, ii, L: Integer;
Colors,SearchCols: TIntegerArray;
begin
Result := False;
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
Dec(B.X2);
Dec(B.Y2);
FindColorsTolerance(TPA, 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;
aTPA := SplitTPAEx(TPA, 20, 20);
SortATPASize(aTPA, True);
B := GetTPABounds(aTPA[0]);
Colors := [13034990, 4231423, 2070783, 65535, 16776960, 9812166];
TextType := LowerCase(TextType);
case TextType of
'action', 'player': SearchCols := [0,5];
'item' : SearchCols := [1,2];
'npc' : SearchCols := [3];
'object': SearchCols := [4];
else
SearchCols := [0,1,2,3,4,5];
end;
L := High(SearchCols);
SetLength(aTPA,l+1);
for i := 0 to l do
FindColorsTolerance(aTPA[I], Colors[SearchCols[I]], B.X1, B.Y1, B.X2, B.Y2, 3);
TPA := MergeATPA(aTPA);
aTPA := SplitTPAEx(TPA, 7, 1);
L := High(aTPA);
H := High(Texts);
SortATPAFromFirstPoint(ATPA, Point(OptionBox.X1, optionbox.y1));
for I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
begin
Result := True;
case Action of
ClickLeft: MouseBoxEx(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5,5, 1);
Move: MouseBoxEx(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5,5, 3);
Nothing: begin end;
else
srl_warn('ChooseOptionMultiEx', 'ClickRight not a valid click for RS menus!', warn_AllVersions);
end;
Exit;
end;
end;
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;
The error on line 558 is SortATPAFromFirstPoint(ATPA, Point(OptionBox.X1, optionbox.y1)), but the problem is that when the optionbox is that big,
aTPA := SplitTPAEx(TPA, 20, 20);
SortATPASize(aTPA, True);
B := GetTPABounds(aTPA[0]);splits the colors on each side of the optionbox into to two TPA's, and then only uses the one on the left side (atpa[0]) for the TBox of where to look for the text.
So FindColorsTolerance(aTPA, Colors[SearchCols], B.X1, B.Y1, B.X2, B.Y2, 3) is basically just looking at a vertical line, because B.X1 and B.X2 are equal.
That means that aTPA doesn't get filled with any of the text color it's looking for, so when SortATPAFromFirstPoint gets called, it gets passed an empty ATPA and then it's out of range when it tries to sort the TPAs.
My question is, why split it up in the first place? I'm pretty sure using
FindColorsTolerance(TPA, 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;
B := GetTPABounds(TPA);
//aTPA := SplitTPAEx(TPA, 20, 20);
//SortATPASize(aTPA, True);
//B := GetTPABounds(aTPA[0]);
would work fine, and it fixes the problem.