SRL Archive - OSR Help

Simple question


Thief

2013-05-22 06:38:07

I'm trying to setup a fail safe for a script, in case the character ends up in a location where they can see an iron rock, but can't reach it.

This is what I've got, but I can't seem to get it to work.

Here are the two procedures.



Procedure WrongSideOfWall;
begin
if FindChatBoxText('You can''t reach that.',8,ClBlack) then
begin
WriteLn('Wrong side of wall, attempting to get to right spot');
end;
end;



Procedure MineOres;
var
x, y, PlusOne, OreCounter: Integer;
begin
MarkTime(TooLong);
PlusOne:= InvCount+1;
If FindObjCustom(x, y, ['ron'], [3491704, 3557754, 3755136, 3294324], 5) Then
begin
FindNormalRandoms;
StatsGuise('Found Iron.');
MMouse (x, y, 5, 5);
ClickMouse2(Mouse_left)
end;

Flag;
MarkTime(OreCounter);
[COLOR="#FF0000"]WrongSideOfWall;[/COLOR]
If (TimeFromMark(TooLong) > 30000) Then
FailSafe('Failed to find Iron.');

repeat
If (TimeFromMark(TooLong) > 30000) Then
FailSafe('Failed to find Iron.');
Antiban;
Wait(100);
If InvCount=PlusOne Then
begin
StatsGuise('Mined a precious Iron.');
Proggy;
end;
until (InvCount=PlusOne) or (TimeFromMark(OreCounter) > 3000+random(1500));
end;

Haxz

2013-05-22 06:41:42

Won't you get error on this line?

if FindChatBoxText('You can''t reach that.',8,ClBlack) then

The word "can't" just ended your string with the '

Flight

2013-05-22 06:51:41

Instead of 'FindChatBoxText('You can''t reach that.',8,ClBlack)' try this:

FindBlackChatMessage('t reach th')

Thief

2013-05-22 07:31:39

From: Haxz
Won't you get error on this line?

if FindChatBoxText('You can''t reach that.',8,ClBlack) then

The word "can't" just ended your string with the '


Nah it doesn't make an error cause I have two ' marks, but maybe it messes up the string.

Instead of 'FindChatBoxText('You can''t reach that.',8,ClBlack)' try this:

FindBlackChatMessage('t reach th')



Thanks Flight, that worked straight away :)


EDIT:

on another note, could anyone tell me what's wrong with the following?

I want the script to retry moving to the right area and click a TPA if it fails to find the TPA.

So far, it will attempt to move to the right area, but just clicks the area 3 times (max attempts) then logs out without trying to click the shortcut again.


Procedure FindShortcut2;
var
PathTPA, WallTPA:TPointArray;
PathATPA:T2DPointArray;
PathBox:TBox;
attempts: integer;
i, r, counter:integer;
begin
if not(loggedin) then
exit;
Wait(RandomRange(2000, 200));
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 0.43);

if FindColorsSpiralTolerance(MSX1, MSY1, PathTPA, 4413280, MSX1, MSY1, MSX2, MSY2, 20) then
begin
PathATPA := SplitTPAEx(PathTPA, 25, 25);
SortATPASize(PathATPA, True);
for i := 0 to high(PathATPA) do
begin
PathBox := GetTPABounds(PathATPA[i]);
SetColorSpeed2Modifiers(0.20, 3.85);

if FindColorsSpiralTolerance(MSX1, MSY1, WallTPA, 12118515, PathBox.X1, Pathbox.Y1, Pathbox.X2, Pathbox.Y2, 10) then
Break;

if i = high(PathATPA) then
begin
WriteLn('Failed to find wall color.');
repeat
Inc(attempts);
RunBack;
Obstaclearea2;
until (i= high(PathATPA) = false) or (attempts > 3); //Meant to move to the right area and re-search for the wall if it doesn't find the colors.
end;

if (attempts > 3) then
begin
StatsGuise('Failed to find shortcut after a few tries, logging out.');
Failsafe('Failed to find wall and path colors.');
Logout;[/COLOR]
end;
end;
SetColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
marktime(counter);
while (not isuptext('wall')) do
begin
r := random(length(WallTPA));
mmouse(WallTPA[r].x, WallTPA[r].y, 2, 2);
wait(randomrange(200, 500));

if timefrommark(counter) > 15000 then
begin
WriteLn('Failed to click the shortcut.'); //Meant to move to the right area and try and click the shortcut again if it fails.
repeat
Obstaclearea2;
Inc(attempts);
until (DidRedClick = true) or (attempts > 3);
end;
if (attempts > 3) then
begin
StatsGuise('Failed to find shortcut after a few tries, logging out.');
Failsafe('Failed to find shortcut after banking.');
Logout;
end;
end;
ClickMouse2(Mouse_left);
end;
Wait(RandomRange(3000, 5000));
end;