haha. So, I feel like you guys are starting to hate me, because I don't ever really post unless it's because I'm having scripting issues.
Though, I promise I'm trying to figure out how to be a decent scripter! Don't hate! 
EDIT: Ok, so I'm back with another question... This time in regards to "ActionBarSlotToBox();". This part of the script I'm trying to search the Action Bar for an object. I want to use "FindObjTPA();" and if it's found, it should return the number of the box. If not, it should Result:= 0;. The issue? If the object isn't found I always get "Error: Out of Range". What am I doing wrong?
Simba Code:
function SearchActionBar(color, tol: Integer; hue, sat: Extended; StartBox, EndBox: Integer; UpText: TStringArray): Integer;
var
actionSlot: TBox;
invPattern: TIntegerArray;
tmpCTS, x, y, I: Integer;
begin
invPattern := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; //Sets array length, and what boxes to search.
tmpCTS:= GetColorToleranceSpeed; //grabs current CTS
ColorToleranceSpeed(2); //sets the CTS to CTS2
SetColorSpeed2Modifiers(hue, sat); //changes the modifiers
for I:= (StartBox) to (EndBox) do //Using a "for..to..do.." loop to search (Duh!)
begin
actionSlot:= ActionBarSlotToBox(invPattern[I]); // "ERROR: Out of Range" happens here
x:= actionSlot.x1+5; //Adjusting the coordinates
y:= actionSlot.y1+5; //just to help FindObjTPA
MMouse(actionSlot.x1, actionSlot.y1, 20, 20); //Just using this to visually see how it searches the box
Writeln('Searching Box '+IntToStr(invPattern[I])); //Debugging Evidence
if FindObjTPA(x, y, color, tol, 2, 4, 4, 12, UpText) then //IF we find the object then...
begin
Writeln('FindObjTPA resulted "True"; Object is in actionSlot['+IntToStr(invPattern[I])+'].');
result:= invPattern[I]; //Should result the number of the box, right?
Exit;
end;
end;
//if we failed to find it then...
SetColorSpeed2Modifiers(0.2, 0.2); //reset the CTS2 modifiers
ColorToleranceSpeed(tmpCTS); //reset the CTS
Result:= 0;
end;
My Original Issue (note: read my edit post to see the fix)
HTML Code:
Ok, I'm sure this will be a quick fix... I just can't get my head around how to solve it though. I've tried a couple different ways, but nothing seems to work. The idea is that it would use SearchInvColor(); to double check the inventory to make sure it's full. Then I wanted to use a custom TPA to find the Crayfish in an Action bar box. I suppose that I could just do coordinates, but what's the fun in that, right?
The problem is that, it seems to search the box for the color, but the TPA length always turns out to be 0 points long. I have no idea why. I've checked my coordinates, so they should be okay. The problem seems to around FindColorsSpiralTolerance();, but I don't know what I'm doing wrong.
Any thoughts?
P.S. All this is to update my Lumbridge Crayfisher, if that wasn't clear.
My Code:
[SIMBA]program new;
{$DEFINE SMART}
{$i srl/srl.simba}
function SearchInvColor(Color, Tol: Integer; Hue, Sat: Extended; StartInvBox, EndInvBox: Integer): Boolean;
var
I, x, y, tmpCTS: integer;
invPattern: TIntegerArray;
slotBox:TBox;
begin
tmpCTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2); //searches using CTS 2
SetColorSpeed2Modifiers(Hue, Sat); //Hue and Sat modifiers
invPattern := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]; //the pattern it searches in
Writeln('Checking for the object in your Inventory.');
for I:= (StartInvBox) to (EndInvBox) do
begin
slotBox:= InvBox(invPattern[I]);
{Writeln('Checking item colors in InvBox['+IntToStr(invPattern[I])+']'); }
if (not FindColorTolerance(x, y, Color, slotBox.x1, slotBox.y1, slotBox.x2, slotBox.y2, Tol)) then
begin
Writeln('Could not find the color in InvBox['+IntToStr(invPattern[I])+']!');
Result:= false;
Exit;
end;
end;
SetColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Writeln('We have confirmed that your inventory is full.');
Result:= true;
end;
procedure DropInventory;
var
Points: TPointArray;
aPoints: T2DPointArray;
myPoint: TPoint;
barBox: TBox;
I, tmpCTS, a, b: Integer;
begin
barBox:= IntToBox(370, 346, 402, 377); //the box the Crayfish will be in
a:= 383; //middle "x" for the box
b:= 364; //middle "y"
if SearchInvColor(1914720, 12, 0.03, 0.11, 0, 27) then //Made to double check inv
begin
tmpCTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.11);
Writeln('Beginning to search the Action Bar for the Crayfish.');
FindColorsSpiralTolerance(a, b, Points, 1914720, barBox.x1, barBox.y1, barBox.x2, barBox.y2, 12);
ColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
if Length(Points) = 0 then //Points will always return "0"
begin //Issue with FindColorsSpiralTolerance?
Writeln('TPA Length is "0".');
Writeln('Object was not found.');
Exit;
end;
Writeln('Object found.');
aPoints:= TPAtoATPAEX(Points, 7, 7);
SetLength(Points, 0);
for I := 0 to High(aPoints) do
begin
if Length(aPoints[i]) < 3 then
Continue;
myPoint := MiddleTPA(aPoints[i]);
MMouse(myPoint.X, myPoint.Y, 3, 3);
end;
end;
ColorToleranceSpeed(tmpCTS);
end;
begin
SetupSRL;
DropInventory;
end.[/SIMBA]