I'm trying to come up with a good way of finding noted forms of items in the inventory for my lazy merchant bot.
I developed these functions to do that, Just thought I would share. Any improvements would be awesome.
Use:
Snippet:Code:writeln(IntToStr(compareColorArrays(GetColorsFromTBox(InvBox(1)), GetColorsFromTBox(InvBox(2)))));
Code:function GetColorsFromTBox(loc : TBox): Array of Integer; var x, y, currentCol, emptySlot, color : Integer; found : boolean; colors : Array[1..100] of Integer; begin for x := loc.X1 to loc.X2 do begin for y := loc.Y1 to loc.Y2 do begin found := false; color := GetColor(x, y); for currentCol := 1 to 100 do begin if colors[currentCol] = color then begin found := true; Break; end; if colors[currentCol] = 0 then begin emptySlot := currentCol; writeln('Filled up slot' + IntToStr(emptySlot) + ' with: ' + IntToStr(color)); Break; end; end; if not(found) then colors[emptySlot] := color; end; end; Result := colors; end; function compareColorArrays(origColors, searchColors : Array of Integer): Integer; var i, i2, colorsFound : Integer; begin for i := Low(origColors) to High(origColors) do begin for i2 := Low(searchColors) to High(searchColors) do begin if origColors[i] = searchColors[i2] then begin colorsFound := colorsFound + 1; Break; end; end; end; Result := colorsFound; end;


Reply With Quote
looks good i dont think theres difference of Noted and not noted items? looks good to me imo maybe some1 may help and how is it going with the Merchanting bot?





