SRL Archive - OSR Help

TPA's on me?!?


rya

2010-03-17 12:26:04

Well i run this and it just moves the mouse of me and not the iron ore im standing right next to, any idea's how to stop this?


program test;
{.include srl/srl.scar}

function WriteAndResult(Text: string; MyResult: Boolean): Boolean;
begin
Result := MyResult;
WriteLn(Text);
end;

function SetOre(Ore, What: Integer): Integer;
begin
case What Of
0: begin //Colour
case Ore of
0: Result := 1;//Bronze Colour
1: Result := 1;//tin colour
2: Result := 2634057;//Iron colour
end;
end;
1: begin
case Ore of //Toll
0: Result :=1;
1: Result :=1;
2: Result :=22;
end;
end;
end;
end;

function FindOre(Ore: Integer): Boolean;
var
Time, Colour, Toll, i, a, x, y, g, h: Integer; //Time = for failsafe latter
MyTpa: TPointArray;
ClickPoint: TPoint;
begin
X := MSCX
Y := MSCY
Colour := SetOre(Ore,0);
Toll := SetOre(Ore,1);

if not FindColorsSpiralTolerance(x, y, MyTpa, Colour, MSX1, MSY1, MSX2, MSY2, Toll) then
Begin
Result := WriteAndResult('Did not find colour :( A sad day ',False);
Exit;
End;

for i := 0 to High(MyTpa) do
begin
ClickPoint := MyTpa[i]
Inc(a);
MMouse(ClickPoint.x, ClickPoint.y, 4, 4);
GetMousePos(g,h);
WriteLn('We clicked at'+IntToStr(G)+(',')+IntToStr(H)+' also I:'+IntToStr(i))
if IsUpText('ine') then
begin
GetMousePos(x, y);
Result := True
if (Random(20) = 5) then
begin
Mouse(x, y, 0, 0, False);
ChooseOption('ine');
Exit;
end else begin
Mouse(x, y, 0, 0, True);
Exit;
end;
if A>=25 then
begin
Result := WriteAndResult('UpText not found after moving mouse 25 time!!!',False);
Exit;
end;
end;
end;//<-- Here
end;

begin
SetupSRL;
ActivateClient;
If FindOre(2) Then
WriteLn('Found ore');
end.
Thanks

~Rya

Stevee

2010-03-17 12:56:38

This line
Colour := SetOre(Ore,[COLOR=#000080]0[/COLOR]);

to

Colour := SetOre(Ore,[COLOR=#000080]2[/COLOR]);

I think. I probably shouldn't be trying to read this, but that's my best guess. It's calling the Bronze color of the first case, not the iron coller.

silor

2010-03-17 13:03:56

I'm currently using this for iron mining at rimmington


type
TRockColor = record
Color: integer;
hue: extended;
sat: extended;
tol: integer;
end;

procedure SetRockColor(var Rock: TRockColor; Color, tol: integer; hue, sat: extended);
begin
Rock.Color := Color;
Rock.tol := tol;
Rock.hue := hue;
Rock.sat := sat;
end;

function FindOre(Ore: string): boolean;
var
x, y: integer;
Rock: TRockColor;
begin
case Ore of
'copper': SetRockColor(Rock, 2847201, 13, 0.01, 1.74);
'tin' : SetRockColor(Rock, 7895424, 17, 0.13, 0.08);
'iron' : SetRockColor(Rock, 2633799, 5, 0.10, 0.28);
'gold' : SetRockColor(Rock, 1094373, 9, 0.01, 1.31);
end;

x := MSCX;
y := MSCY;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Rock.hue, Rock.sat);
if FindObjTPA(x, y, 2633799, 5, 2, 26,29, 3, ['Mine', 'Rocks']) then
begin
Wait(100 + Random(100));
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
result := true;
end;
end;

rya

2010-03-17 13:04:39

From: Stevee
This line
Colour := SetOre(Ore,[COLOR=#000080]0[/COLOR]);

to

Colour := SetOre(Ore,[COLOR=#000080]2[/COLOR]);

I think. I probably shouldn't be trying to read this, but that's my best guess. It's calling the Bronze color of the first case, not the iron coller.


You have it worng the first parameter is the ore which is set in calling the function the 0 bit your talking about is the 'what' case
its does sometimes find the ore BTW
But thaks for trying to help

E: @silor thanks but im looking to fx this so i know whats happening in what i make

silor

2010-03-17 13:27:57

From: rya
E: @silor thanks but im looking to fx this so i know whats happening in what i make


Alright, well first you have a tolerance of 22 with CTS 1 which probably find plenty of other things than iron ore, then it will loop through everything it found starting from main screen center so it finds the color on your character first.

If you want to stop that you have to find a unique color to iron ore with as low tol as possible and using CTS 2, I suggest using Auto Color Aid.. Or you could use FindObjTPA which will do all that for you and find the iron ore. :)