@@ -155,7 +155,6 @@ begin
155155 for i := 0 to High(unique) do
156156 begin
157157 best := GetBestColor(EColorSpace.HSL, unique[i]);
158- WriteLn best;
159158 Result.Finder.Colors += [best.Color, best.Tolerance*1.5, EColorSpace.HSL, [best.Mods[0]*1.5, best.Mods[1]*1.5, best.Mods[2]*1.5]];
160159 end;
161160
@@ -395,12 +394,12 @@ end;
395394(*
396395## TRSEntity._UpTextCheck
397396```pascal
398- function TRSEntity._UpTextCheck(out shouldExit: Boolean): Boolean;
397+ function TRSEntity._UpTextCheck(out shouldExit: Boolean; action: TStringArray ): Boolean;
399398```
400399Internal TRSEntity helper method that is used by all hovering methods.
401400You probably don't need to use this directly.
402401*)
403- function TRSEntity._UpTextCheck(out shouldExit: Boolean): Boolean;
402+ function TRSEntity._UpTextCheck(out shouldExit: Boolean; action: TStringArray ): Boolean;
404403var
405404 text: String;
406405begin
@@ -414,7 +413,7 @@ begin
414413
415414 text := MainScreen.UpText;
416415
417- if text.Contains('>') and not Self.Walker^.ActionUpText .Contains(['>']) then
416+ if text.Contains('>') and not action .Contains(['>']) then
418417 begin
419418 ChooseOption.Close();
420419 Exit;
@@ -429,19 +428,19 @@ end;
429428(*
430429## TRSEntity._HoverHelper
431430```pascal
432- function TRSEntity._HoverHelper(attempts: Integer; trackTarget: Boolean ): Boolean;
431+ function TRSEntity._HoverHelper(action: TStringArray; attempts: Integer ): Boolean;
433432```
434433Internal helper method used to hover a TRSEntity target.
435434You should not use this directly.
436435*)
437- function TRSEntity._HoverHelper(attempts: Integer): Boolean;
436+ function TRSEntity._HoverHelper(action: TStringArray; attempts: Integer): Boolean;
438437var
439438 shouldExit: Boolean;
440439 attempt, i: Integer;
441440 atpa: T2DPointArray;
442441 coordinates, tpa: TPointArray;
443442begin
444- Result := Self._UpTextCheck(shouldExit);
443+ Result := Self._UpTextCheck(shouldExit, action );
445444 if shouldExit then Exit;
446445
447446 for attempt := 0 to attempts do
@@ -475,14 +474,14 @@ end;
475474(*
476475## TRSEntity._WalkHoverHelper
477476```pascal
478- function TRSEntity._WalkHoverHelper(attempts: Integer; trackTarget: Boolean ): Boolean;
477+ function TRSEntity._WalkHoverHelper(action: TStringArray; attempts: Integer ): Boolean;
479478```
480479Internal helper method used to walk and hover a TRSEntity target.
481480You should not use this directly.
482481
483482This is responsible for deciding wether we should walk to a TRSEntity target or not before attempting to hover it.
484483*)
485- function TRSEntity._WalkHoverHelper(attempts: Integer): Boolean;
484+ function TRSEntity._WalkHoverHelper(action: TStringArray; attempts: Integer): Boolean;
486485var
487486 shouldExit: Boolean;
488487 attempt, i: Integer;
491490 path: TGraphNodeArray;
492491 me, closest: TPoint;
493492begin
494- Result := Self._UpTextCheck(shouldExit) or Self.Walker^.RedClicked;
493+ Result := Self._UpTextCheck(shouldExit, action ) or Self.Walker^.RedClicked;
495494 if shouldExit then Exit;
496495
497496 for attempt := 0 to attempts do
@@ -577,9 +576,6 @@ This is what's responsible for deciding if we click a target we are hovering or
577576*)
578577function TRSEntity._ClickHelper(leftClick: Boolean): Boolean;
579578begin
580- Self.Walker^.TargetUpText := [];
581- Self.Walker^.ActionUpText := [];
582-
583579 if Self.Walker^.RedClicked then
584580 begin
585581 Self.Walker^.RedClicked := False;
@@ -612,9 +608,6 @@ This is what is responsible for deciding if we just left click a target we are h
612608*)
613609function TRSEntity._SelectHelper(action: TStringArray): Boolean;
614610begin
615- Self.Walker^.TargetUpText := [];
616- Self.Walker^.ActionUpText := [];
617-
618611 if Self.Walker^.RedClicked then
619612 begin
620613 Self.Walker^.RedClicked := False;
@@ -634,18 +627,16 @@ end;
634627(*
635628## TRSEntity.Hover
636629```pascal
637- function TRSEntity.Hover(attempts: Integer = 2; trackTarget: Boolean = TRSEntity.TrackTarget ): Boolean;
630+ function TRSEntity.Hover(action: TStringArray = []; attempts: Integer = 2 ): Boolean;
638631```
639632Method used to hover a TRSEntity target if it's found on the mainscreen.
640- It can update the target position while the mouse moves with **trackTarget**.
641633
642634Example:
643635```pascal
644- RSW.WebWalk(WaspWeb.LOCATION_VARROCK);
645- RSObjects.GEBank.Hover(); //Be in GE with a walker setup there.
636+ //TODO...
646637```
647638*)
648- function TRSEntity.Hover(attempts: Integer = 2): Boolean;
639+ function TRSEntity.Hover(action: TStringArray = []; attempts: Integer = 2): Boolean;
649640begin
650641 if ChooseOption.IsOpen() then
651642 begin
@@ -662,25 +653,22 @@ begin
662653 //TODO:
663654 //if not Self.Walker^.MakePointVisible(Self.Coordinates) then Exit;
664655
665- Result := Self._HoverHelper(attempts);
656+ Result := Self._HoverHelper(action, attempts);
666657end;
667658
668659(*
669660## TRSEntity.WalkHover
670661```pascal
671- function TRSEntity.WalkHover(attempts: Integer = 2; trackTarget: Boolean = TRSEntity.TrackTarget ): Boolean;
662+ function TRSEntity.WalkHover(action: TStringArray = []; attempts: Integer = 2 ): Boolean;
672663```
673664Method used to walk and hover a TRSEntity target if it's found on the mainscreen after walking.
674- It can update the target position while the mouse moves with **trackTarget**.
675665
676666Example:
677667```pascal
678- //Be in varrock with a varrock map loaded.
679- RSW.WebWalk(WaspWeb.LOCATION_VARROCK);
680- RSObjects.GEBank.WalkHover();
668+ //TODO...
681669```
682670*)
683- function TRSEntity.WalkHover(attempts: Integer = 2): Boolean;
671+ function TRSEntity.WalkHover(action: TStringArray = []; attempts: Integer = 2): Boolean;
684672var
685673 me, closest: TPoint;
686674 path: TGraphNodeArray;
@@ -693,9 +681,6 @@ begin
693681 ChooseOption.Close();
694682 end;
695683
696- if Self.UpText <> [] then
697- Self.Walker^.TargetUpText := Copy(Self.UpText);
698-
699684 me := Self.Walker^.Position();
700685 closest := Self.Walker^.GetClosestPoint(me, Self.Coordinates, path);
701686
@@ -708,17 +693,25 @@ begin
708693 hasPath := True;
709694 end;
710695
696+ Self.Walker^.TargetUpText := Copy(Self.UpText);
697+ Self.Walker^.ActionUpText := action;
698+
699+ try
711700 // check if doors need to be passed to reach target
712- if hasPath or Self.Walker^.WebGraph^.WalkableClusters.InSameTPA(me, closest) then
713- begin
714- if not Self.Walker^.MakePointVisible(closest) and not Self.Walker^.WebWalkEx(me, closest, 30, 0.15) then
701+ if hasPath or Self.Walker^.WebGraph^.WalkableClusters.InSameTPA(me, closest) then
702+ begin
703+ if not Self.Walker^.MakePointVisible(closest) and not Self.Walker^.WebWalkEx(me, closest, 30, 0.15) then
704+ Exit;
705+ end
706+ else
707+ if not Self.Walker^.WebWalk(closest, 30, 0.15) then
715708 Exit;
716- end
717- else
718- if not Self.Walker^.WebWalk(closest, 30, 0.15) then
719- Exit;
720709
721- Result := Self._WalkHoverHelper(attempts);
710+ Result := Self._WalkHoverHelper(action, attempts);
711+ finally
712+ Self.Walker^.TargetUpText := [];
713+ Self.Walker^.ActionUpText := [];
714+ end;
722715end;
723716
724717
@@ -737,7 +730,7 @@ WriteLn RSObjects.GEBank.Click();
737730*)
738731function TRSEntity.Click(leftClick: Boolean = True; attempts: Integer = 2): Boolean;
739732begin
740- Result := Self.Hover(attempts) and Self._ClickHelper(leftClick);
733+ Result := Self.Hover([], attempts) and Self._ClickHelper(leftClick);
741734end;
742735
743736(*
@@ -749,9 +742,7 @@ Method used to select an option on a TRSEntity target if it's found on the mains
749742*)
750743function TRSEntity.Interact(action: TStringArray; attempts: Integer = 2): Boolean;
751744begin
752- Self.Walker^.ActionUpText := action;
753- Result := Self.Hover(attempts) and Self._SelectHelper(action);
754- Self.Walker^.ActionUpText := [];
745+ Result := Self.Hover(action, attempts) and Self._SelectHelper(action);
755746end;
756747
757748(*
@@ -774,8 +765,7 @@ begin
774765 if Self.Coordinates = [] then
775766 raise GetDebugLn('TRSEntity', 'FindFrom requires the object to have coordinates.');
776767
777- Result := Self.WalkHover(attempts) and Self._ClickHelper(leftClick);
778- Self.Walker^.TargetUpText := [];
768+ Result := Self.WalkHover([], attempts) and Self._ClickHelper(leftClick);
779769end;
780770
781771(*
@@ -792,12 +782,7 @@ begin
792782 if Self.Coordinates = [] then
793783 raise GetDebugLn('TRSEntity', 'FindFrom requires the object to have coordinates.');
794784
795- Self.Walker^.ActionUpText := action;
796-
797- Result := Self.WalkHover(attempts) and Self._SelectHelper(action);
798-
799- Self.Walker^.TargetUpText := [];
800- Self.Walker^.ActionUpText := [];
785+ Result := Self.WalkHover(action, attempts) and Self._SelectHelper(action);
801786end;
802787
803788
0 commit comments