SRL Archive - OSR Help

TimeFromMark


Sk1nyNerd

2014-02-01 14:20:06

shouldnt i be logging out after 5seconds if a tree isnt found? I MarkTime(FindTreeTime) in the begining of FindTree procedure but if i stand in the middle of no where it will just continue bouncing the mouse around on similiar colors looking for trees or not move at all and not logout. i also tried calling MarkTime before the FindTree Procedure but same thing.

repeat
FindTree;
if (TimeFromMark(FindTreeTime) > 5000) then
begin
writeln('Unable to find any trees...');
LogOut;
TerminateScript;
end;
CheckInv;
until(LogsCut = CutLogs);

Unfold

2014-02-01 15:42:14

Make sure your procedure is not constantly updating the marktime…

like add a writeln after it so you can see how many times it is marking the time.

If you would like, PM me your script and i could check whats wrong

The Mayor

2014-02-01 15:59:20

Post the rest of the script, can't see anything in that snippet

Sk1nyNerd

2014-02-01 16:09:30

if im litterally in the middle of no where with no matching colors it will log out after 5 seconds but if it finds a matching color but not the right uptext it wont log out.

find tree function:

function FindTree: Boolean;
var
TPA, TempTPA: TPointArray;
ATPA: Array of TPointArray;
i, x, y, a, b, MinPoints, CTS: Integer;
Colors, Tolerances: TIntegerArray;
HueMods, SatMods: TExtendedArray;
TreePoint, TempPoint: TPoint;

begin

Result:= False;

Status := ('Searching for tree...');
Report;
InvLogs := CountItems('DTM', LogDTM, []);

if ((rs_GetCompassAngleDegrees < 85) or (rs_GetCompassAngleDegrees > 110)) then
MakeCompass(randomrange(85,110));

Colors := [5014947, 4359279];
Tolerances := [15, 20];
HueMods := [0.02, 0.02];
SatMods := [0.57, 0.31];
MinPoints := 15;

CTS:= GetToleranceSpeed;
SetColorToleranceSpeed(2);

for i:= 0 to High(Colors) do
begin
SetToleranceSpeed2Modifiers(Huemods[i], SatMods[i]);
FindColorsTolerance(TempTPA, Colors[i], MSX1, MSY1, MSX2, MSY2, Tolerances[i]);
AppendTPA(TPA, TempTPA);
end;

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (High(TPA)> 0) then
begin

ATPA:= SplitTPA(TPA,10);
SortATPASize(ATPA,True);

for i:= 0 to High(ATPA) do
begin
if (High(ATPA[i]) < MinPoints) then
Break;
end;

if (i = 0) then
Exit;

SetArrayLength(ATPA,i);
SortATPAFromFirstPoint(ATPA,Point(MSCX,MSCY));

for i:= Low(ATPA) to Min(High(ATPA),3) do
begin
MiddleTPAEX(ATPA[i],x,y);
TreePoint:= Point(x,y);
MMouse(randomrange(x-5,x+5),randomrange(y-5,y+5),0,0);
if WaitUpTextMulti(['hop','own'],randomrange(150,600)) then
begin
if (IsUpTextMultiCustom(['hop','own'])) then
begin
HumanWait;
HumanMouseClick;
if (DidRedClick) then
begin
Result:= True;
Status:= ('Chopping tree...');
Report;
Exit;
end;
end;
end;
end;

end else
if (TimeFromMark(FindTreeTime) > 5000) then
begin
writeln('Unable to find any trees...');
LogOut;
TerminateScript;
end;
writeln('kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk');
FindTree;


end;

mainloop:

repeat
MarkTime(FindTreeTime);
FindTree;
CheckInv;
until(LogsCut = CutLogs);

private script so im not gonna post the whole code @The Mayor i can pm it to you if this isnt enough

Kyle

2014-02-01 16:36:19

@ibot_dung11 Yeah, It seems like it is looping so fast that when it gets to the mark, it hasn't had enough time elapsed to be more than 5 secs. The it goes and loops over it like Unfold said and starts it over.

EDIT: Probably should post a way to fix it lol. :p I would take the marktime out of the repeating loop, and add it into the part where it clicks the tree when it finds it. So everytime it finds the tree it resets the time, then if it goes for a few loops and doesn't find it, enough time will have elapsed. You can also do it with a integer variable that increases each loop and when it finds it, it resets it to 0. So if the integer is higher than 5 or something, it has not found it for 5 loops.
Hopefully that made sense :) If not just skype me or you can pm me.

The Mayor

2014-02-01 17:19:22

From: ibot_dung11


private script so im not gonna post the whole code @The Mayor i can pm it to you if this isnt enough


Ok, it was timing out if it didn't find colors, but not timing out if it found no uptext because…..you told it to.


function FindTree: Boolean;
var
TPA, TempTPA: TPointArray;
ATPA: Array of TPointArray;
i, x, y, a, b, MinPoints, CTS: Integer;
Colors, Tolerances: TIntegerArray;
HueMods, SatMods: TExtendedArray;
TreePoint, TempPoint: TPoint;

begin

Result:= False;

Status := ('Searching for tree...');
Report;
InvLogs := CountItems('DTM', LogDTM, []);

if ((rs_GetCompassAngleDegrees < 85) or (rs_GetCompassAngleDegrees > 110)) then
MakeCompass(randomrange(85,110));

Colors := [5014947, 4359279];
Tolerances := [15, 20];
HueMods := [0.02, 0.02];
SatMods := [0.57, 0.31];
MinPoints := 15;

CTS:= GetToleranceSpeed;
SetColorToleranceSpeed(2);

for i:= 0 to High(Colors) do
begin
SetToleranceSpeed2Modifiers(Huemods[i], SatMods[i]);
FindColorsTolerance(TempTPA, Colors[i], MSX1, MSY1, MSX2, MSY2, Tolerances[i]);
AppendTPA(TPA, TempTPA);
end;

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (High(TPA)> 0) then
begin

ATPA:= SplitTPA(TPA,10);
SortATPASize(ATPA,True);

for i:= 0 to High(ATPA) do
begin
if (High(ATPA[i]) < MinPoints) then
Break;
end;

if (i = 0) then
Exit;

SetArrayLength(ATPA,i);
SortATPAFromFirstPoint(ATPA,Point(MSCX,MSCY));

for i:= Low(ATPA) to Min(High(ATPA),3) do
begin
MiddleTPAEX(ATPA[i],x,y);
TreePoint:= Point(x,y);
MMouse(randomrange(x-5,x+5),randomrange(y-5,y+5),0,0);
if WaitUpTextMulti(['hop','own'],randomrange(150,600)) then
begin
if (IsUpTextMultiCustom(['hop','own'])) then
begin
HumanWait;
HumanMouseClick;
if (DidRedClick) then
begin
Result:= True;
Status:= ('Chopping tree...');
Report;
Exit; // I guess you could mark time here, so it resets each time you click a tree
end;
end;
end; // if the text doesnt match, it ends here, and nothing happens
end; // and it wont run the else statement below as it's not part of the same statement

end else // if it doesn't find a color it will run this else statement
if (TimeFromMark(FindTreeTime) > 5000) then
begin // yo could just delete the else, and have this if statement separate
writeln('Unable to find any trees...');
LogOut;
TerminateScript;
end;
writeln('kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk');
FindTree; // why this?


end

Sk1nyNerd

2014-02-01 20:04:43

From: elfyyy
@ibot_dung11 I would take the marktime out of the repeating loop, and add it into the part where it clicks the tree when it finds it. So everytime it finds the tree it resets the time, then if it goes for a few loops and doesn't find it, enough time will have elapsed. You can also do it with a integer variable that increases each loop and when it finds it, it resets it to 0. So if the integer is higher than 5 or something, it has not found it for 5 loops.
Hopefully that made sense :) If not just skype me or you can pm me.


thanks, i moved the timer where both of you suggested and added another else statement where The Mayor stated (i didnt realize that). works like a charm thanks guys :)

sorry elfyyy it wont let me +1 you:( lol

edit: this will work temporary. otherwise it logsouts after cutting the tree down and not clicking on the one next to it. ill play with it, thanks guys
From: The Mayor
Ok, it was timing out if it didn't find colors, but not timing out if it found no uptext because…..you told it to.


if (DidRedClick) then
begin
Result:= True;
Status:= ('Chopping tree...');
Report;
Exit; // I guess you could mark time here, so it resets each time you click a tree
end;
end;
end; // if the text doesnt match, it ends here, and nothing happens
end; // and it wont run the else statement below as it's not part of the same statement

end else // if it doesn't find a color it will run this else statement
if (TimeFromMark(FindTreeTime) > 5000) then
begin // yo could just delete the else, and have this if statement separate
writeln('Unable to find any trees...');
LogOut;
TerminateScript;
end;
writeln('kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk');
FindTree; // why this?


end