
Originally Posted by
Heavenguard
Ugh, Can you tell me whats wrong with this script. Im telling scar to walk out of the bank and click on the road at a certain point(s). But it just clickes the compass and sets the direction north, and tells me that it DID click the road.
program LearningDDTM;
{.include SRL/SRL.scar}
var
DDTMTolerance : Integer; // We declare DDTMTolerance globally as we want to use it in more then function;
function SetDDTM: Integer;// We declare the function SetDDTM which returns an Integer.
var
dtmMainPoint: TDTMPointDef; // TDTMPointDef is just words for Main Point.
dtmSubPoints: Array [0..4] of TDTMPointDef; // These are the subpoints of the Main Point.
TempTDTM: TDTM; // TDTM is the DDTM.
RoadColor : Integer; // This is going to be the roadcolor for Varrock's Road.
begin
RoadColor := FindVarrockRoadColor; // Here is were we introduce the autocolor include. FindVarrockRoadColor is a handy function which automatically finds the Color of the road in Varrock.
dtmMainPoint.x := 891; // The MainPoint X coordinate.
dtmMainPoint.y := 247; // The MainPoint Y coordinate.
dtmMainPoint.AreaSize := 1; // The MainPoint AreaSize, the bigger the number, the bigger the area it searches.
dtmMainPoint.AreaShape := 0; // The MainPoint AreaShape, 0 means X. 1 Means Square.
dtmMainPoint.Color := RoadColor; // The MainPoint Color, This is what makes this function Dynamic, as RoadColor makes the color change.
dtmMainPoint.Tolerance := DDTMTolerance; // The Tolerance of finding that MainPoint Color, The higher this number, the more it searches.
dtmSubPoints[0].x := 891; // The Subpoint of [0], X coordinate.
dtmSubPoints[0].y := 247; // The Subpoint of [0], Y coordinate.
dtmSubPoints[0].AreaSize := 1; // The Subpoint of [0], The AreaSize.
dtmSubPoints[0].AreaShape := 0;// The Subpoint of [0], The AreaShape.
dtmSubPoints[0].Color := RoadColor;// The Subpoint of [0], The Color.
dtmSubPoints[0].Tolerance := DDTMTolerance;// The Subpoint of [0], The Tolerance.
dtmSubPoints[1].x := 888;
dtmSubPoints[1].y := 239;
dtmSubPoints[1].AreaSize := 1;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := RoadColor;
dtmSubPoints[1].Tolerance := DDTMTolerance;
dtmSubPoints[2].x := 889;
dtmSubPoints[2].y := 227;
dtmSubPoints[2].AreaSize := 1;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := RoadColor;
dtmSubPoints[2].Tolerance := DDTMTolerance;
dtmSubPoints[3].x := 892;
dtmSubPoints[3].y := 258;
dtmSubPoints[3].AreaSize := 1;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := RoadColor;
dtmSubPoints[3].Tolerance := DDTMTolerance;
dtmSubPoints[4].x := 895;
dtmSubPoints[4].y := 257;
dtmSubPoints[4].AreaSize := 1;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := RoadColor;
dtmSubPoints[4].Tolerance := DDTMTolerance;
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;
Function WalkOutOfBank : Boolean;
var
TheDDTM, x, y : Integer; // The DDTM is an Integer because SetDDTM returns an Integer.
begin
if not LoggedIn then Exit; // if your not logged in, Scar will automatically stop the script there.
SetRun(True);// This enables Running in Runescape.
DDTMTolerance := 5;// Remember the DDTM Tolerance we declared globally? well here we use it.
TheDDTM := SetDDTM;// Here we say that TheDDTM is actually the function SetDDTM.
repeat // This thing repeats until its told to end.
if not DTMRotated(TheDDTM, x, y, MMX1, MMY1, MMX2, MMY2) then // DTMRotated just tells scar that if the minimap is not adjusted correctly to see the coordinates of TheDDTM then..
begin
Writeln('DDTM not Found, Adjusting Tolerance (Increasing)');
IncEx(DDTMTolerance, 5);// IncEx increases the integer by the number specified.
FreeDTM(TheDDTM); // Frees the DDTM, It is IMPORTANT that you do this. It drops the DDTM and all of its settings after this.
TheDDTM := SetDDTM ; // we declare it again since FreeDTM(TheDDTM) Resets it.
end else
begin
Writeln('Found Varrock Road!!');
Mouse(x, y, 4, 4, true);// Moves mouse to X, Y and left clicks it.
Result := True; // The Result is true after clicking.
Break;// Breaks the LOOP! it stops it right here! If you do not break this loop, Line 71's if not will continue to increase the tolerence. Until 50.
end;
until((DDTMTolerance >=50) or not LoggedIn);//it will repeatedly try to find the DDTM until the tolerance is greater or equal to 50, or your account has logged out, or it the DDTM has been found.
DDTMTolerance := 5;// We reset the DDTMTolerance to 5. So we can use it again if needed.
FreeDTM(TheDDTM);// We free it again anyways. since this is the end of the function.
end;
begin
SetupSRL;
ClearDebug;
ActivateClient;
if WalkOutOfBank then
Writeln('We have walked out of the Bank!')
else
Writeln('We have not Walked out of the Bank!');
end.
Are my colors just screwed up?
Use scar tags bud.
SCAR Code:
program LearningDDTM;
{.include SRL/SRL.scar}
var
DDTMTolerance : Integer; // We declare DDTMTolerance globally as we want to use it in more then function;
function SetDDTM: Integer;// We declare the function SetDDTM which returns an Integer.
var
dtmMainPoint: TDTMPointDef; // TDTMPointDef is just words for Main Point.
dtmSubPoints: Array [0..4] of TDTMPointDef; // These are the subpoints of the Main Point.
TempTDTM: TDTM; // TDTM is the DDTM.
RoadColor : Integer; // This is going to be the roadcolor for Varrock's Road.
begin
RoadColor := FindVarrockRoadColor; // Here is were we introduce the autocolor include. FindVarrockRoadColor is a handy function which automatically finds the Color of the road in Varrock.
dtmMainPoint.x := 891; // The MainPoint X coordinate.
dtmMainPoint.y := 247; // The MainPoint Y coordinate.
dtmMainPoint.AreaSize := 1; // The MainPoint AreaSize, the bigger the number, the bigger the area it searches.
dtmMainPoint.AreaShape := 0; // The MainPoint AreaShape, 0 means X. 1 Means Square.
dtmMainPoint.Color := RoadColor; // The MainPoint Color, This is what makes this function Dynamic, as RoadColor makes the color change.
dtmMainPoint.Tolerance := DDTMTolerance; // The Tolerance of finding that MainPoint Color, The higher this number, the more it searches.
dtmSubPoints[0].x := 891; // The Subpoint of [0], X coordinate.
dtmSubPoints[0].y := 247; // The Subpoint of [0], Y coordinate.
dtmSubPoints[0].AreaSize := 1; // The Subpoint of [0], The AreaSize.
dtmSubPoints[0].AreaShape := 0;// The Subpoint of [0], The AreaShape.
dtmSubPoints[0].Color := RoadColor;// The Subpoint of [0], The Color.
dtmSubPoints[0].Tolerance := DDTMTolerance;// The Subpoint of [0], The Tolerance.
dtmSubPoints[1].x := 888;
dtmSubPoints[1].y := 239;
dtmSubPoints[1].AreaSize := 1;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := RoadColor;
dtmSubPoints[1].Tolerance := DDTMTolerance;
dtmSubPoints[2].x := 889;
dtmSubPoints[2].y := 227;
dtmSubPoints[2].AreaSize := 1;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := RoadColor;
dtmSubPoints[2].Tolerance := DDTMTolerance;
dtmSubPoints[3].x := 892;
dtmSubPoints[3].y := 258;
dtmSubPoints[3].AreaSize := 1;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := RoadColor;
dtmSubPoints[3].Tolerance := DDTMTolerance;
dtmSubPoints[4].x := 895;
dtmSubPoints[4].y := 257;
dtmSubPoints[4].AreaSize := 1;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := RoadColor;
dtmSubPoints[4].Tolerance := DDTMTolerance;
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;
Function WalkOutOfBank : Boolean;
var
TheDDTM, x, y : Integer; // The DDTM is an Integer because SetDDTM returns an Integer.
begin
if not LoggedIn then Exit; // if your not logged in, Scar will automatically stop the script there.
SetRun(True);// This enables Running in Runescape.
DDTMTolerance := 5;// Remember the DDTM Tolerance we declared globally? well here we use it.
TheDDTM := SetDDTM;// Here we say that TheDDTM is actually the function SetDDTM.
repeat // This thing repeats until its told to end.
if not DTMRotated(TheDDTM, x, y, MMX1, MMY1, MMX2, MMY2) then // DTMRotated just tells scar that if the minimap is not adjusted correctly to see the coordinates of TheDDTM then..
begin
Writeln('DDTM not Found, Adjusting Tolerance (Increasing)');
IncEx(DDTMTolerance, 5);// IncEx increases the integer by the number specified.
FreeDTM(TheDDTM); // Frees the DDTM, It is IMPORTANT that you do this. It drops the DDTM and all of its settings after this.
TheDDTM := SetDDTM ; // we declare it again since FreeDTM(TheDDTM) Resets it.
end else
begin
Writeln('Found Varrock Road!!');
Mouse(x, y, 4, 4, true);// Moves mouse to X, Y and left clicks it.
Result := True; // The Result is true after clicking.
Break;// Breaks the LOOP! it stops it right here! If you do not break this loop, Line 71's if not will continue to increase the tolerence. Until 50.
end;
until((DDTMTolerance >=50) or not LoggedIn);//it will repeatedly try to find the DDTM until the tolerance is greater or equal to 50, or your account has logged out, or it the DDTM has been found.
DDTMTolerance := 5;// We reset the DDTMTolerance to 5. So we can use it again if needed.
FreeDTM(TheDDTM);// We free it again anyways. since this is the end of the function.
end;
begin
SetupSRL;
ClearDebug;
ActivateClient;
if WalkOutOfBank then
Writeln('We have walked out of the Bank!')
else
Writeln('We have not Walked out of the Bank!');
end.