Add sleep duration in world fetching loop#171
Open
XxXAdvisaryXxX wants to merge 1 commit intoWaspScripts:mainfrom
Open
Add sleep duration in world fetching loop#171XxXAdvisaryXxX wants to merge 1 commit intoWaspScripts:mainfrom
XxXAdvisaryXxX wants to merge 1 commit intoWaspScripts:mainfrom
Conversation
Super Small Sleep to allow ``Word.Bounds`` to be cached while scrollbar is not moving. Before it was just too fast and would mis-cache ``World.Bounds`` and would click and hop to wrong world. When it did that, ``Self.WaitSwitch(next) then Exit`` wasn't working because ``self.World <> next``. The small sleep made it cache the right position and hop to the correct ``next`` world.
Contributor
Author
|
Here's The Snippet I used to figure it out. The fix is commented out and there are writelns to see what's happening. {$I Wasplib/osrs.simba}
function TRSWorldSwitcher._Hop(next: Integer): Boolean; Override;
var
timeout: TCountDown;
available: TRSWorldArray;
world: TRSWorld;
begin
if not Self.IsSorted() and not Self.Sort() then
Exit;
timeout.Start(20 * ONE_SECOND);
repeat
//Sleep(20,40);
available := Self.GetWorlds();
if available = [] then Exit;
for world in available do
if world.Number = next then
begin
WriteLn 'Entered Next Loop';
WriteLn ('Current World :' , self.World);
Mouse.Click(world.Bounds, EMouseButton.LEFT);
WriteLn next;
if Self.WaitSwitch(next) then
Exit(True);
end;
Self.Scroll.Scroll(Biometrics.RandomModeInteger(2,1,3), next > available[0].Number);
until not InRange(Self.Scroll.GetLevel(), 1, 99) or timeout.IsFinished;
end;
function TRSWorldSwitcher.WaitSwitch(world: Integer; failCooldown: Boolean = True): Boolean; override;
begin
if not SleepUntil(MainScreen.IsServerMessage('Please wait'), 200, 3*TICK) then
begin
if failCooldown then
Self.Cooldown.Restart(0, 7000);
Exit;
end;
Result := SleepUntil(Self.World = world, 200, 10000);
WriteLn ('World after Hop: ' , Self.World);
end;
begin
WorldSwitcher.Random();
end; ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Super Small Sleep to allow
Word.Boundsto be cached while scrollbar is not moving. Before it was just too fast and would mis-cacheWorld.Boundsand would click and hop to wrong world.When it did that,
Self.WaitSwitch(next) then Exitwasn't working becauseself.World <> next.The small sleep made it cache the right position and hop to the correct
nextworld.