Simba Code:
program counting;
{$i srl-6/srl.simba}
{$i ETL_LAPE.simba}
const
clientArea:= IntToBox(8 ,4,416,323);
var
backpack:tbox;
backpackslots:TboxArray;
backpackslotwidth,Backpackslotheight:integer;
slot: integer;
x,y:integer
function waitClientReady(): boolean;override;
begin
result:=true;
end;
Procedure prepareinvgrid;
var
backpack:tbox;
backpackslots:TboxArray;
backpackslotwidth,Backpackslotheight:integer;
slot: integer;
begin
backpack:= intToBox(564, 214, 719, 457);
Backpackslotwidth:= round(backpack.getWidth/4);
Backpackslotheight:= round(backpack.getHeight/7);
backpackslots:= backpack.split(Backpackslotwidth,Backpackslotheigh t);
//slot:=8;
ETL_Start();
//mouse (backpackslots[slot-1] .getMIddle, MOUSE_LEFT,MOUSE_ACCURATE);
//ETL_DrawBox(backpackslots[slot-1],cLblue,true);
ETL_Drawboxes(backpackslots, true);
end;
Function ItemInSlot(slotnum:integer):boolean;
begin
if findColorSpiral(x,y, 65536, backpackslots[slotnum-1]) then ////ERROR LINE HERE///////////
result := true;
end;
function InvoCount:integer;
var
i,items:integer;
text:string;
begin
for i:= 1 to 28 do
begin
if ItemInSlot(i) then
begin
inc(items);
ETL_Drawbox(backpackslots[i-1],cLblue,true);
end;
end;
text:= 'total items ' +toStr(items);
ETL_DrawTextEx(317,486, Upchars07_s, text, cLblue, false);
result:= items;
end;
function InvoIsFull:boolean;
begin
if InvoCount = 28 then result:= true;
end;
begin
waitClientReady;
Setupsrl;
ETL_Start;
prepareinvgrid;
InvoCount;
end;
I believe you're passing in 0 as the slotNumber. That 0 gets evaluated to -1 (0 - 1), which throws an access violation.