Boreas
02-24-2007, 05:57 AM
NOTE: I have found a situation where this technique doesn't work. I have developed a new technique that will work all the time, but is a little more complicated (but in some ways easier). This method is still best for somethings (staffs), so both methods will be available. See post 10 for more details.
Bank Browsing- BlackLists w/ FindColorTolerance
Level: Intermediate but you must read this first LINK TO BLACKLIST TUT (http://www.villavu.com/forum/showthread.php?t=6229?t=7151)
About B4 and this series of tutorials-
I am developing a system called B4 (Bank Browser By Boreas) made up of functions for finding, withdrawing, and depositing bank items. It will be fast and efficient, using techniques especially designed for using minimal resources and still getting the job done. One of the features will be only searching for something once, and then remembering where it is. It will also be easy to use, with high level functions like MakeInventory('18 coal, 9 iron'); that will take care of everything. It will also make DTM/bitmap/color creation easier, so you can spend more time scripting. As well as the high level functions like MakeInventory, it will contain many lower level functions that you can combine to make your own personalized higher level functions. This series of tutorials will teach you how to use the functions, and how they work. It is partly a user manual for the B4 system, but it is also a series of scripting tutorial, teaching problem solving, scripting techniques, and ways of thinking. The more you know about how something works, the better you can use it. All of these tutorials will be labeled intermediate or advanced. The material will not be too tricky, but I do expect you to be comfortable with arrays etc. Also, B4 will make banking very easy, but I still want beginner scripters to learn the old fashioned way of doing it. Therefore, these tutorials are for intermediate-advanced scripters who want to spend less time writing banking routines and more time on interesting things, although you may also learn some scripting techniques too.
About this tutorial-
If you have read the BlackList tutorial (if not, do that first) you that a BlackList for a steel bar will be the same for a gold bar. This tutorial will go over how to tell the difference, once the BlackLists have narrowed it down.
How do we tell the difference? There are multiple ways; DTMs/Bitmaps/Colors (uptext moves the mouse, we will do that later) but they all come down to one thing, color. Since the color isn't static like the black (65536) we also need tolerance. Now we don't need anything fancy, FindColorTolerance will do. The way we use it is where it gets fancy.
FindColorTolerance looks for multiple colors (tolerance) in multiple pixels (in a specified box). This won't bring your computer to a grinding halt, but if we can minimize the effect, then why not? First off the tolerance, make this as small as you can get away with. You can use various utilities to help with this, I'll leave it to you to figure out because it's different for different items. The second part is the area to search in, that's where we can really improve. Before I talk more about that, let's start at the beginning.
Ok let's say we are looking for a fire rune, and we have other runes such as air, and one BlackList would work for both. The BlackList tutorial shows how to check whether a specific item fits a BlackList. Let's expand on this by finding an item that fits, in fact all items that fit.
Check this out:
{************************************************* ******************************
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
By: Boreas
Description: Returns true if TheInt is a member of TheArray
************************************************** ****************************}
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
var i:integer;
begin
repeat
if TheArray[i]=TheInt then
result:=true;
i:=i+1;
until ((i=getarraylength(TheArray)) or (result));
end;
{************************************************* ******************************
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
By: Boreas
Description: Returns the BankSlots containing the BlackList found with the
PointList. Skips the slots in SkipEm. Use [0] to skip none.
************************************************** ****************************}
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
var slot,counter:integer;
tmpBlackList, tmpresult:array of integer;
begin
for slot:=1 to 48 do
begin
if not(InIntArray(slot,SkipEm)) then //is there a better way?
begin
tmpBlackList:=CreateItemBlackList(slot,PointList);
if CompareIntArrays(BlackList,tmpBlackList) then
begin
setarraylength(tmpresult,counter+1);
tmpresult[counter]:=slot;
counter:=counter+1;
end;
end;
end;
result:=tmpresult;
end;
It returns a integer array of all the spots that have the same BlackList as the one specified.
Notice it can also skip an array of spots. If you know it's not somewhere, then why bother looking there? B4 will make more use of this feature with chains of functions that accept spots check/skip and return spots for the next one to look at, until there is 1. For now, just put [0].
Here it is in action
program New;
{.include SRL/SRL.scar}
var MyList:TPointArray;
var tmpList,tmpList2:array of integer;
var t:integer;
{************************************************* ******************************
function Create40PercentTPA:TPointArray;
By: Boreas
Note: Purely an internal function, used in setup.
Description: Returns a TPointArray containing the relative (to x1,y1 of a BSlot)
for 385 points (out of 31*31, hence 40%). Only needs to be done once, to create
the list of points to check for 65536. Only takes like 15ms, and I didn't
feel like typing them all out.
************************************************** *****************************}
function Create40PercentTPA:TPointArray;
var Counter,hx,hy:integer;
var TPointsToCheck:array [0..384] of TPoint;
begin
repeat
hy:=15;
hx:=hx+1;
repeat
hy:=hy+1;
if (((hx mod 4)=0) or ((hy mod 4)=0)) then
begin
TPointsToCheck[Counter].x:=hx;
TPointsToCheck[Counter].y:=hy;
Counter:=Counter+1;
end;
until hy=31;
until hx=31;
result:=TPointsToCheck;
end;
{************************************************* ******************************
function CreateItemBlackList(WhichBankSlot:integer;WhichLis t:TPointArray):array of integer;
By: Boreas
Description: Looks at the points in the list for an item, and returns an array
contatining the indexes of the points that are black.
Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
containing positions relative to the x1,y1 of a bankslot which you want to check
************************************************** *****************************}
function CreateItemBlackList(WhichBankSlot:integer;WhichLis t:TPointArray):array of integer;
var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
var TmpArray:array of integer;
begin
Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
ListLength:=getarraylength(WhichList)-1;
setarraylength(tmparray,1);
for Counter:= 0 to ListLength do
begin
if GetColor(Tmpx1+WhichList[Counter].x,Tmpy1+WhichList[Counter].y)=65536 then
begin
TmpArray[Counter2]:=Counter;
Counter2:=Counter2+1;
setarraylength(TmpArray,Counter2+1);
end;
end;
result:=TmpArray;
end;
{************************************************* ******************************
function CompareIntArrays(FirstIntArray,SecondIntArray:arra y of integer):boolean;
By: Boreas
Description: Returns true both arrays are the same
************************************************** ****************************}
function CompareIntArrays(FirstIntArray,SecondIntArray:arra y of integer):boolean;
var Counter:integer;
begin
if not(getarraylength(FirstIntArray)=getarraylength(S econdIntArray)) then
result:=false;
if (getarraylength(FirstIntArray)=getarraylength(Seco ndIntArray)) then
begin
result:=true;
repeat
if not(FirstIntArray[Counter]=SecondIntArray[Counter]) then
result:=false;
Counter:=Counter+1;
until ((Counter=getarraylength(FirstIntArray)) or (result=false));
end;
end;
//in misc/arrayloader.scar by moparisthebest
function intArrayToStr(intArray: array of Integer): string;
var
i, arrayLength: Integer;
begin
arrayLength := GetArrayLength(intArray);
repeat
Result := Result + IntToStr(intArray[i]);
if (not (i = (arrayLength - 1))) then
Result := Result + ' ';
i := i + 1;
until (i = arrayLength)
end;
//in misc/arrayloader.scar by moparisthebest
function strToIntArray(intArray: string): array of Integer;
var
i, spacePos: Integer;
begin
repeat
SetArrayLength(Result, i + 1);
spacePos := Pos(' ', intArray);
if (not (spacePos = 0)) then
begin
Result[i] := StrToInt(Copy(intArray, 1, spacePos - 1));
end
else
begin
Result[i] := StrToInt(Copy(intArray, 1, Length(intArray)));
break;
end;
Delete(intArray, 1, spacePos);
i := i + 1;
until (False)
end;
{************************************************* ******************************
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
By: Boreas
Description: Returns true if TheInt is a member of TheArray
************************************************** ****************************}
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
var i:integer;
begin
repeat
if TheArray[i]=TheInt then
result:=true;
i:=i+1;
until ((i=getarraylength(TheArray)) or (result));
end;
{************************************************* ******************************
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
By: Boreas
Description: Returns the BankSlots containing the BlackList found with the
PointList. Skips the slots in SkipEm. Use [0] to skip none.
************************************************** ****************************}
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
var slot,counter:integer;
tmpBlackList, tmpresult:array of integer;
begin
for slot:=1 to 48 do
begin
if not(InIntArray(slot,SkipEm)) then //is there a better way?
begin
tmpBlackList:=CreateItemBlackList(slot,PointList);
if CompareIntArrays(BlackList,tmpBlackList) then
begin
setarraylength(tmpresult,counter+1);
tmpresult[counter]:=slot;
counter:=counter+1;
end;
end;
end;
result:=tmpresult;
end;
begin
t:=getsystemtime;
MyList:=Create40PercentTPA;
tmplist:=CreateItemBlackList(6,MyList);
tmplist2:=findallslotsblacklistskip(tmplist,MyList ,[0]);
writeln(intarraytostr(tmplist2));
writeln(inttostr(getsystemtime-t));
end.
http://img180.imageshack.us/img180/7964/bankcq0.th.png (http://img180.imageshack.us/my.php?image=bankcq0.png)
So now we have 4 slots in which the fire rune could be. Each slot is 31 by 31 pixels, making 3844 pixels all together. But we can do better than that. Items do not move around in their BankSlots. This means the middle of the rune is always the same distance away from the top left corner of the BankSlot, no matter which slot it is in. Remember this fact. Another fact is, the color that distinguishes the fire rune from the rest (red) is not all over the rune, or the slot. It is in the middle. So lets have the FindColorTolerance just look there. So lets get the coordinates of the area you want to look in. Not so fast. We want it to work in any slot, so we want coordinates of the box to be relative to the top left corner of the slot. Lucky for you, I have something for that.
program New;
procedure CreateBoxRelativeToBankSlot;
var x1,y1,x2,y2,slot1,slot2,tmpx,tmpy:integer;
begin
writeln('Put the mouse at the top left of the box');
writeln('Then press F12');
repeat
wait(30);
until isfkeydown(12);
GetMousePos(x1,y1);
slot1:=(((((y1-62) div 38)+1)-1)*8)+(((x1-79) div 47)+1);
tmpx:=79+((((Slot1+7)mod 8))*47);
tmpy:=62+((((Slot1-1)/8))*38);
x1:=x1-tmpx;
y1:=y1-tmpy;
writeln('Put the mouse at the bottom right of the box');
writeln('Then press F11');
repeat
wait(30);
until isfkeydown(11);
GetMousePos(x2,y2);
slot2:=(((((y2-62) div 38)+1)-1)*8)+(((x2-79) div 47)+1);
tmpx:=79+((((Slot2+7)mod 8))*47);
tmpy:=62+((((Slot2-1)/8))*38);
x2:=x2-tmpx;
y2:=y2-tmpy;
if not(slot1=slot2) then writeln('Error try again');
writeln('x1= '+inttostr(x1));
writeln('y1= '+inttostr(y1));
writeln('x2= '+inttostr(x2));
writeln('y2= '+inttostr(y2));
end;
begin
CreateBoxRelativeToBankSlot;
end.
Should be pretty self explanatory, but I'll do it anyway. Run the script on the pic. Move your mouse to top left corner of the box you want look in (around the red). Press F12. Do the same for the bottom right and press F11. Lemme know if I need to make pics of me doing this.
You should get something like
x1= 14
y1= 23
x2= 17
y2= 25
So thanks to the find all BlackList function, we know which slots to look in. Thanks to the box creator, we know where in each slot to look. You figure out the color and tolerance. Now we have everything for this
{************************************************* ******************************
function FindColorTolBanksSlots(color,tolerance,x1,y1,x2,y2 :integer; Slots:array of integer):array of integer;
By: Boreas
Description: Returns array of BankSlots which contain the color with tol in the
box relative to top left of bank slots.
************************************************** ****************************}
function FindColorTolBanksSlots(color,tolerance,x1,y1,x2,y2 :integer; Slots:array of integer):array of integer;
var tmpx,tmpy,Counter, ResultCounter:integer;
tmpresult:array of integer;
begin
for Counter:=0 to getarraylength(Slots)-1 do
begin
tmpx:=79+((((Slots[Counter]+7)mod 8))*47);
tmpy:=62+((((Slots[Counter]-1)/8))*38);
if FindColorTolerance(tmpx,tmpy,color,Slotx1+x1,Sloty 1+y1,Slotx1+x2,Sloty1+y2,tolerance) then
begin
setarraylength(tmpresult,ResultCounter+1);
tmpresult[ResultCounter]:=Counter;
ResultCounter:=ResultCounter+1;
end;
end;
result:=tmpresult;
end;
Similar to the other function, it looks at some spots, and returns which one(s) it narrowed down to. If for some reason this returns more than 1 result, you can narrow it down in the same fashion with another method (probably uptext). You can figure out how to write that from this, I may add it later if you really want.
I think that about covers it, I feel like I'm forgetting something though.
Please note that is a small technique, to be combined with others. It is a very small part of B4, and doesn't do that much without the rest. But I thought I would post it here now so you can use it if you want. Plus, unlike most of B4, this doesn't require any edits to SRL, or lower level supporting functions (because it is one) besides the ones I posted above and in the BlackList tutorial.
Please note this tutorial is very rough. If anyone is interested and needs me to clean it up a bit, I will. Any questions, feel free to ask. Since I created it, it's hard for me to explain it, as I was never taught it, so I may have left out important parts lol.
Bank Browsing- BlackLists w/ FindColorTolerance
Level: Intermediate but you must read this first LINK TO BLACKLIST TUT (http://www.villavu.com/forum/showthread.php?t=6229?t=7151)
About B4 and this series of tutorials-
I am developing a system called B4 (Bank Browser By Boreas) made up of functions for finding, withdrawing, and depositing bank items. It will be fast and efficient, using techniques especially designed for using minimal resources and still getting the job done. One of the features will be only searching for something once, and then remembering where it is. It will also be easy to use, with high level functions like MakeInventory('18 coal, 9 iron'); that will take care of everything. It will also make DTM/bitmap/color creation easier, so you can spend more time scripting. As well as the high level functions like MakeInventory, it will contain many lower level functions that you can combine to make your own personalized higher level functions. This series of tutorials will teach you how to use the functions, and how they work. It is partly a user manual for the B4 system, but it is also a series of scripting tutorial, teaching problem solving, scripting techniques, and ways of thinking. The more you know about how something works, the better you can use it. All of these tutorials will be labeled intermediate or advanced. The material will not be too tricky, but I do expect you to be comfortable with arrays etc. Also, B4 will make banking very easy, but I still want beginner scripters to learn the old fashioned way of doing it. Therefore, these tutorials are for intermediate-advanced scripters who want to spend less time writing banking routines and more time on interesting things, although you may also learn some scripting techniques too.
About this tutorial-
If you have read the BlackList tutorial (if not, do that first) you that a BlackList for a steel bar will be the same for a gold bar. This tutorial will go over how to tell the difference, once the BlackLists have narrowed it down.
How do we tell the difference? There are multiple ways; DTMs/Bitmaps/Colors (uptext moves the mouse, we will do that later) but they all come down to one thing, color. Since the color isn't static like the black (65536) we also need tolerance. Now we don't need anything fancy, FindColorTolerance will do. The way we use it is where it gets fancy.
FindColorTolerance looks for multiple colors (tolerance) in multiple pixels (in a specified box). This won't bring your computer to a grinding halt, but if we can minimize the effect, then why not? First off the tolerance, make this as small as you can get away with. You can use various utilities to help with this, I'll leave it to you to figure out because it's different for different items. The second part is the area to search in, that's where we can really improve. Before I talk more about that, let's start at the beginning.
Ok let's say we are looking for a fire rune, and we have other runes such as air, and one BlackList would work for both. The BlackList tutorial shows how to check whether a specific item fits a BlackList. Let's expand on this by finding an item that fits, in fact all items that fit.
Check this out:
{************************************************* ******************************
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
By: Boreas
Description: Returns true if TheInt is a member of TheArray
************************************************** ****************************}
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
var i:integer;
begin
repeat
if TheArray[i]=TheInt then
result:=true;
i:=i+1;
until ((i=getarraylength(TheArray)) or (result));
end;
{************************************************* ******************************
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
By: Boreas
Description: Returns the BankSlots containing the BlackList found with the
PointList. Skips the slots in SkipEm. Use [0] to skip none.
************************************************** ****************************}
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
var slot,counter:integer;
tmpBlackList, tmpresult:array of integer;
begin
for slot:=1 to 48 do
begin
if not(InIntArray(slot,SkipEm)) then //is there a better way?
begin
tmpBlackList:=CreateItemBlackList(slot,PointList);
if CompareIntArrays(BlackList,tmpBlackList) then
begin
setarraylength(tmpresult,counter+1);
tmpresult[counter]:=slot;
counter:=counter+1;
end;
end;
end;
result:=tmpresult;
end;
It returns a integer array of all the spots that have the same BlackList as the one specified.
Notice it can also skip an array of spots. If you know it's not somewhere, then why bother looking there? B4 will make more use of this feature with chains of functions that accept spots check/skip and return spots for the next one to look at, until there is 1. For now, just put [0].
Here it is in action
program New;
{.include SRL/SRL.scar}
var MyList:TPointArray;
var tmpList,tmpList2:array of integer;
var t:integer;
{************************************************* ******************************
function Create40PercentTPA:TPointArray;
By: Boreas
Note: Purely an internal function, used in setup.
Description: Returns a TPointArray containing the relative (to x1,y1 of a BSlot)
for 385 points (out of 31*31, hence 40%). Only needs to be done once, to create
the list of points to check for 65536. Only takes like 15ms, and I didn't
feel like typing them all out.
************************************************** *****************************}
function Create40PercentTPA:TPointArray;
var Counter,hx,hy:integer;
var TPointsToCheck:array [0..384] of TPoint;
begin
repeat
hy:=15;
hx:=hx+1;
repeat
hy:=hy+1;
if (((hx mod 4)=0) or ((hy mod 4)=0)) then
begin
TPointsToCheck[Counter].x:=hx;
TPointsToCheck[Counter].y:=hy;
Counter:=Counter+1;
end;
until hy=31;
until hx=31;
result:=TPointsToCheck;
end;
{************************************************* ******************************
function CreateItemBlackList(WhichBankSlot:integer;WhichLis t:TPointArray):array of integer;
By: Boreas
Description: Looks at the points in the list for an item, and returns an array
contatining the indexes of the points that are black.
Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
containing positions relative to the x1,y1 of a bankslot which you want to check
************************************************** *****************************}
function CreateItemBlackList(WhichBankSlot:integer;WhichLis t:TPointArray):array of integer;
var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
var TmpArray:array of integer;
begin
Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
ListLength:=getarraylength(WhichList)-1;
setarraylength(tmparray,1);
for Counter:= 0 to ListLength do
begin
if GetColor(Tmpx1+WhichList[Counter].x,Tmpy1+WhichList[Counter].y)=65536 then
begin
TmpArray[Counter2]:=Counter;
Counter2:=Counter2+1;
setarraylength(TmpArray,Counter2+1);
end;
end;
result:=TmpArray;
end;
{************************************************* ******************************
function CompareIntArrays(FirstIntArray,SecondIntArray:arra y of integer):boolean;
By: Boreas
Description: Returns true both arrays are the same
************************************************** ****************************}
function CompareIntArrays(FirstIntArray,SecondIntArray:arra y of integer):boolean;
var Counter:integer;
begin
if not(getarraylength(FirstIntArray)=getarraylength(S econdIntArray)) then
result:=false;
if (getarraylength(FirstIntArray)=getarraylength(Seco ndIntArray)) then
begin
result:=true;
repeat
if not(FirstIntArray[Counter]=SecondIntArray[Counter]) then
result:=false;
Counter:=Counter+1;
until ((Counter=getarraylength(FirstIntArray)) or (result=false));
end;
end;
//in misc/arrayloader.scar by moparisthebest
function intArrayToStr(intArray: array of Integer): string;
var
i, arrayLength: Integer;
begin
arrayLength := GetArrayLength(intArray);
repeat
Result := Result + IntToStr(intArray[i]);
if (not (i = (arrayLength - 1))) then
Result := Result + ' ';
i := i + 1;
until (i = arrayLength)
end;
//in misc/arrayloader.scar by moparisthebest
function strToIntArray(intArray: string): array of Integer;
var
i, spacePos: Integer;
begin
repeat
SetArrayLength(Result, i + 1);
spacePos := Pos(' ', intArray);
if (not (spacePos = 0)) then
begin
Result[i] := StrToInt(Copy(intArray, 1, spacePos - 1));
end
else
begin
Result[i] := StrToInt(Copy(intArray, 1, Length(intArray)));
break;
end;
Delete(intArray, 1, spacePos);
i := i + 1;
until (False)
end;
{************************************************* ******************************
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
By: Boreas
Description: Returns true if TheInt is a member of TheArray
************************************************** ****************************}
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
var i:integer;
begin
repeat
if TheArray[i]=TheInt then
result:=true;
i:=i+1;
until ((i=getarraylength(TheArray)) or (result));
end;
{************************************************* ******************************
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
By: Boreas
Description: Returns the BankSlots containing the BlackList found with the
PointList. Skips the slots in SkipEm. Use [0] to skip none.
************************************************** ****************************}
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
var slot,counter:integer;
tmpBlackList, tmpresult:array of integer;
begin
for slot:=1 to 48 do
begin
if not(InIntArray(slot,SkipEm)) then //is there a better way?
begin
tmpBlackList:=CreateItemBlackList(slot,PointList);
if CompareIntArrays(BlackList,tmpBlackList) then
begin
setarraylength(tmpresult,counter+1);
tmpresult[counter]:=slot;
counter:=counter+1;
end;
end;
end;
result:=tmpresult;
end;
begin
t:=getsystemtime;
MyList:=Create40PercentTPA;
tmplist:=CreateItemBlackList(6,MyList);
tmplist2:=findallslotsblacklistskip(tmplist,MyList ,[0]);
writeln(intarraytostr(tmplist2));
writeln(inttostr(getsystemtime-t));
end.
http://img180.imageshack.us/img180/7964/bankcq0.th.png (http://img180.imageshack.us/my.php?image=bankcq0.png)
So now we have 4 slots in which the fire rune could be. Each slot is 31 by 31 pixels, making 3844 pixels all together. But we can do better than that. Items do not move around in their BankSlots. This means the middle of the rune is always the same distance away from the top left corner of the BankSlot, no matter which slot it is in. Remember this fact. Another fact is, the color that distinguishes the fire rune from the rest (red) is not all over the rune, or the slot. It is in the middle. So lets have the FindColorTolerance just look there. So lets get the coordinates of the area you want to look in. Not so fast. We want it to work in any slot, so we want coordinates of the box to be relative to the top left corner of the slot. Lucky for you, I have something for that.
program New;
procedure CreateBoxRelativeToBankSlot;
var x1,y1,x2,y2,slot1,slot2,tmpx,tmpy:integer;
begin
writeln('Put the mouse at the top left of the box');
writeln('Then press F12');
repeat
wait(30);
until isfkeydown(12);
GetMousePos(x1,y1);
slot1:=(((((y1-62) div 38)+1)-1)*8)+(((x1-79) div 47)+1);
tmpx:=79+((((Slot1+7)mod 8))*47);
tmpy:=62+((((Slot1-1)/8))*38);
x1:=x1-tmpx;
y1:=y1-tmpy;
writeln('Put the mouse at the bottom right of the box');
writeln('Then press F11');
repeat
wait(30);
until isfkeydown(11);
GetMousePos(x2,y2);
slot2:=(((((y2-62) div 38)+1)-1)*8)+(((x2-79) div 47)+1);
tmpx:=79+((((Slot2+7)mod 8))*47);
tmpy:=62+((((Slot2-1)/8))*38);
x2:=x2-tmpx;
y2:=y2-tmpy;
if not(slot1=slot2) then writeln('Error try again');
writeln('x1= '+inttostr(x1));
writeln('y1= '+inttostr(y1));
writeln('x2= '+inttostr(x2));
writeln('y2= '+inttostr(y2));
end;
begin
CreateBoxRelativeToBankSlot;
end.
Should be pretty self explanatory, but I'll do it anyway. Run the script on the pic. Move your mouse to top left corner of the box you want look in (around the red). Press F12. Do the same for the bottom right and press F11. Lemme know if I need to make pics of me doing this.
You should get something like
x1= 14
y1= 23
x2= 17
y2= 25
So thanks to the find all BlackList function, we know which slots to look in. Thanks to the box creator, we know where in each slot to look. You figure out the color and tolerance. Now we have everything for this
{************************************************* ******************************
function FindColorTolBanksSlots(color,tolerance,x1,y1,x2,y2 :integer; Slots:array of integer):array of integer;
By: Boreas
Description: Returns array of BankSlots which contain the color with tol in the
box relative to top left of bank slots.
************************************************** ****************************}
function FindColorTolBanksSlots(color,tolerance,x1,y1,x2,y2 :integer; Slots:array of integer):array of integer;
var tmpx,tmpy,Counter, ResultCounter:integer;
tmpresult:array of integer;
begin
for Counter:=0 to getarraylength(Slots)-1 do
begin
tmpx:=79+((((Slots[Counter]+7)mod 8))*47);
tmpy:=62+((((Slots[Counter]-1)/8))*38);
if FindColorTolerance(tmpx,tmpy,color,Slotx1+x1,Sloty 1+y1,Slotx1+x2,Sloty1+y2,tolerance) then
begin
setarraylength(tmpresult,ResultCounter+1);
tmpresult[ResultCounter]:=Counter;
ResultCounter:=ResultCounter+1;
end;
end;
result:=tmpresult;
end;
Similar to the other function, it looks at some spots, and returns which one(s) it narrowed down to. If for some reason this returns more than 1 result, you can narrow it down in the same fashion with another method (probably uptext). You can figure out how to write that from this, I may add it later if you really want.
I think that about covers it, I feel like I'm forgetting something though.
Please note that is a small technique, to be combined with others. It is a very small part of B4, and doesn't do that much without the rest. But I thought I would post it here now so you can use it if you want. Plus, unlike most of B4, this doesn't require any edits to SRL, or lower level supporting functions (because it is one) besides the ones I posted above and in the BlackList tutorial.
Please note this tutorial is very rough. If anyone is interested and needs me to clean it up a bit, I will. Any questions, feel free to ask. Since I created it, it's hard for me to explain it, as I was never taught it, so I may have left out important parts lol.