SRL Archive - News and General

Tarray


wantonman

2011-08-01 05:27:08

If TArray is a sring of colors then how does it know x and y?

to rephrase, if in an array there are more than one color, then how does it know to click one piont(x,y)?

BraK

2011-08-01 06:00:21

By TArray do you mean TPointArray? if so then the points of the Colors location are stored not the colors themselves. If you mean TIntegerArray which most people use to input colors then It doesn't store points.

~Brak


Var
TP: TPointArray;
TI: TIntegerArray;

begin
TP := [Point(1,5),Point(2,6)];
TI := [1231423, 1231234, 123123];
end.

Just something I threw together. :)

Smarter Child

2011-08-01 06:25:38

From: wantonman
If TArray is a sring of colors then how does it know x and y?

to rephrase, if in an array there are more than one color, then how does it know to click one piont(x,y)?


Well depends, as BraK explained in a TPointArray, each Point contains an X/Y coordinate, hence an Array of TPoints.

If you are referring to an array of colours, it is most probably a TIntegerArray.

If you are wondering how it knows x/y .. the most commonly used TIntegerArray I have seen in color script is basically like this:
Procedure TIntegerArrayExample;
var
ColorArray: TIntegerArray; //Declares var as TIntegerArray
i, x, y: integer;
begin
ColorArray := [0, 1, 2, 3]; //Loads the array of Colors
for i := 0 to High(ColorArray)do //Cycles through the Color Array
begin
FindColorTolerance(x, y, ColorArray[i], MSX1, MSY1, MSX2, MSY2, 5); //FindColor!
end;
end;

Really, it cycles through through the ColorArray, then when FindColorTolerance finds a colour it will store the coordinates of where it found the colour to the X and Y variables, hence allowing you to use those variables to your advantage. Example, MMouse(x, y, 0, 0); etc.

It would be similar to a TPointArray, in that all the TPoints are made up of x/y coords ;)

If you want to learn more about this sort of thing and how it applies to Runescape then I highly recommend reading this tutorial: A low down on WizzyPlugin and TPA's

BraK

2011-08-01 06:29:23

Nice expansion Smarter Child ;) I didn't have the Time to write it up when I posted it before. Rep+

~BraK

Smarter Child

2011-08-01 06:39:09

From: BraK
Nice expansion Smarter Child ;) I didn't have the Time to write it up when I posted it before. Rep+

~BraK


Thanks :)

masterBB

2011-08-01 07:03:38

Procedure TIntegerArrayExample;
var
ColorArray: TIntegerArray; //Declares var as TIntegerArray
ColorsFound: Array of TPointArray; //Also known as T2DPointArray, Is an array containing multiple arrays
i, x, y: integer;
begin
ColorArray := [0, 1, 2, 3]; //Loads the array of Colors
setLength(ColorsFound,Length(ColorArray)); //Reserves space so that every color got its own TPointArray
for i := 0 to High(ColorArray)do //Cycles through the Color Array
begin
FindColorsTolerance(ColorsFound[i], ColorArray[i], MSX1, MSY1, MSX2, MSY2, 5); //FindColor!
end;
print(ColorsFound);
end;

Coult print something like:
[[[0,0],[2,3],[1,3]], //Points with color 0, ColorsFound[0]
[[1,0],[3,3]], //Points with color 1, ColorsFound[1]
[[0,1],[4,3],[4,4]], //Points with color 2, ColorsFound[2]
[[1,1],[1,3]]] //Points with color 3, ColorsFound[3]