SRL Archive - SRL Suggestions

CountItemsBlackline not working?


Bonfield

2010-09-15 06:30:19

I tried to use CountItemBlackline, butv couldnt really get it to work so i made this

function GetBlackline(InvSlot: Integer): Integer;
var
b: TBox;
begin
b := InvBox(InvSlot);
Result := CountColor(SRL_OUTLINE_BLACK, b.x1, b.y1, b.x2, b.y2);
end;

function CountItems_BlackLine(Count, Start_Slot, Finish_Slot: Integer): Integer;
var
i: Integer;
begin
Result := 0;
GameTab(tab_inv);
for i := Start_Slot to Finish_Slot do
if (GetBlackline(i) = Count) then
Inc(Result);
end;

feedback?

EDIT: how can i save the results to an array, eg an item exists in inventory spots 2-10, i want to save the spots with the correct numbers of black pixels so i can choose a random spot to bank

eg [2, 4, 5, 6, 9, 28]

i want to bank one of those, but i dont know how to save the results to an array

Bonfield

2010-09-15 07:33:57

solved thanks to Dans The Man

here it is

function GetBlackline(InvSlot: Integer): Integer;
var
b: TBox;
begin
b := InvBox(InvSlot);
Result := CountColor(SRL_OUTLINE_BLACK, b.x1, b.y1, b.x2, b.y2);
end;

function CountItems_BlackLine(Count, Start_Slot, Finish_Slot: Integer; out Slots: array of Integer): Integer;
var
i: Integer;
begin
SetLength(Slots, 28);
Result := 0;
GameTab(tab_Inv);

for I := Start_Slot to Finish_Slot do
if(GetBlackline(I) = Count) then
begin
Inc(Result);
Slots[Result - 1] := I;
end;

SetLength(Slots, Result);
end;

var
ItemCount, forI: Integer;
SlotsIn: array of Integer { same thing as TIntegerArray } ;

begin
ItemCount := CountItems_BlackLine(98, 1, 28, SlotsIn);
Writeln('There are ' + IntToStr(ItemCount) + ' items with 98 black pixels in ' +
'inventory slots 1 to 28');

Writeln('These items were located in:');
for forI := 0 to ItemCount - 1 do
Writeln('Slot ' + IntToStr(SlotsIn[forI]));



end.