SRL Archive - OSR Help

Differentiating between identical looking invetory items


Wreck

2012-06-02 13:56:11

Lets say i had 28 items in my inventory that all looked the same except one of them was called B while the other 27 were called A how could I search through them one by one and then writeln('Found Item') when the uptext B has been found.

Procedure Example;
var
TPA: TPointArray;
DTM: Integer;
begin
DTM := DTMFromString('1234');
if FindDTMs(DTM, TPA, MIX1, MIY2, MIX2, MIY2) then
begin

end;
FreeDTM(DTM);
end;

Is as far as I have managed to get :duh:

Sex

2012-06-02 14:06:13

If they are really identical as in the icon doesn't differ at all then you'll HAVE to check the uptext and even a human would have to do so. A better way would be to track the spots the certain item is in at the time it enters the inventory. You'd have to use the IsUpText or IsUpTextMultiCustom function :).

bolshak25

2012-06-02 14:07:48

can i ask what the items are?

Wreck

2012-06-02 14:13:10

From: bolshak25
can i ask what the items are?


Nothing special just Lletya teleport crystals.

Brandon

2012-06-02 14:13:53

Solutions without RAASTPA can have multiple points for one object so I used it to narrow it down to a single point per object. ATPA's can be used but that's not even necessary.. I'd use solution 1 personally. Not only that but if you want more than one point per object, then remove the RAASTPA. It's pretty neat.


Procedure Solution1;
var
TPA: TPointArray;
DTM, I, L: Integer;
begin
DTM:= DTMFromString('.............');

If FindDTMs(DTM, TPA, MIX1, MIY1, MIX2, MIY2) then
begin
RAASTPAEx(TPA, 10, 10);
L:= High(TPA);

For I:= 0 To L Do
begin
MMouse(TPA[I].X, TPA[I].Y, 0, 0);
If IsUptextMultiCustom(['......', '.....', '.......']) then
ClickMouse2(MOUSE_LEFT);
end;
end;

FreeDTM(DTM);
end;

Procedure Solution2;
var
TPA: TPointArray;
ATPA: T2DPointArray;
DTM, I, L, X, Y: Integer;
begin
DTM:= DTMFromString('.............');

If FindDTMs(DTM, TPA, MIX1, MIY1, MIX2, MIY2) then
begin
ATPA:= TPAToATPAEx(TPA, 10, 10);
L:= High(ATPA);
For I:= 0 To L Do
begin
RAASTPAEx(ATPA[I], 10, 10);
MiddleTPAEx(ATPA[I], X, Y);
MMouse(X, Y, 0, 0);
If IsUptextMultiCustom(['......', '.....', '.......']) then
ClickMouse2(MOUSE_LEFT);
end;
end;

FreeDTM(DTM);
end;

Wreck

2012-06-02 15:26:23

From: Brandon
Solutions without RAASTPA can have multiple points for one object so I used it to narrow it down to a single point per object. ATPA's can be used but that's not even necessary.. I'd use solution 1 personally. Not only that but if you want more than one point per object, then remove the RAASTPA. It's pretty neat.


Procedure Solution1;
var
TPA: TPointArray;
DTM, I, L: Integer;
begin
DTM:= DTMFromString('.............');

If FindDTMs(DTM, TPA, MIX1, MIY1, MIX2, MIY2) then
begin
RAASTPAEx(TPA, 10, 10);
L:= High(TPA);

For I:= 0 To L Do
begin
MMouse(TPA[I].X, TPA[I].Y, 0, 0);
If IsUptextMultiCustom(['......', '.....', '.......']) then
ClickMouse2(MOUSE_LEFT);
end;
end;

FreeDTM(DTM);
end;

Procedure Solution2;
var
TPA: TPointArray;
ATPA: T2DPointArray;
DTM, I, L, X, Y: Integer;
begin
DTM:= DTMFromString('.............');

If FindDTMs(DTM, TPA, MIX1, MIY1, MIX2, MIY2) then
begin
ATPA:= TPAToATPAEx(TPA, 10, 10);
L:= High(ATPA);
For I:= 0 To L Do
begin
RAASTPAEx(ATPA[I], 10, 10);
MiddleTPAEx(ATPA[I], X, Y);
MMouse(X, Y, 0, 0);
If IsUptextMultiCustom(['......', '.....', '.......']) then
ClickMouse2(MOUSE_LEFT);
end;
end;

FreeDTM(DTM);
end;


Went with solution 1 as you advised worked perfectly thanks! Should be releasing my script within the next couple of days :)