SRL Archive - SRL Suggestions

function FindWorldScroll(W :Integer) :Boolean;


Home

2012-05-23 13:14:06

Hello, this function will find the world from WolrdScreen by using your Mouse Scroll Wheel.

You don't have to order worlds, nor it doesn't matter at what position the Runescape Scroll Wheel is, it will Scan the world from up to down and vice versa.

I tried to make the scrolling as human as possible.

I need suggestions etc what else to add. From what I see, it's finished.
I wanted to post here before I do pull request.

Un-comment code from below script to try it without SRL.

I haven't tested this with SMART yet.

(*
FindWorldScroll
~~~~~~~~~~~~~~~

.. code-block:: pascal

function FindWorldScroll(W :Integer) :Boolean;

Scrolls to area using scroll wheel and returns true if world was found.

..note::

by Home

Example:

.. code-block:: pascal

*)

function FindWorldScroll(W :Integer) :Boolean;
var
CurW, Dir, WX, WY, X, Y, I :Integer;
MousePoint :TPoint;
begin
if not WorldScreen then
Exit;

WS_CurrentWorld(CurW);
if (W = CurW) then
begin
Result := True;
WriteLn('Already on world ' + IntToStr(W));
Exit;
end;

if (W = 0) then
begin
srl_Warn('FindWorldScroll', 'World Number cannot be 0', warn_AllVersions);
Exit;
end;

Dir := - 1;

for I := 1 to RandomRange(100, 105) do
begin
If FindText(WX, WY, ' ' + IntToStr(W) + ' ', StatChars, 91, 138, 145, 436) then
begin
{Wait(RandomRange(100, 150));
If FindText(WX, WY, ' ' + IntToStr(W) + ' ', StatChars, 91, 138, 145, 436) then
begin
MMouse(WX + 80, WY, 20, 5);
Result := True;
Exit;
end;}
Result := True;
Exit;
end;

If CountColorTolerance(4807267, 684, 386, 697, 420, 66) > 420 then Dir := 1;

If Random(10) = 0 then
SleepAndMoveMouse(RandomRange(100, 350))
else
Wait(RandomRange(17, 23));

GetMousePos(X, Y);
MousePoint := Point(X, Y);
If Not PointInBox(MousePoint, IntToBox(75, 143, 691, 414)) then
MouseBoxEx(75, 143, 691, 414, 0, mouse_move);
Scrollmouse(0, 0, Dir);

if I > 30 then
If CountColorTolerance(4807267, 685, 155, 696, 186, 66) > 380 then
begin
srl_Warn('FindWorldScroll', 'World '+IntToStr(W)+' Can''t be found ', warn_AllVersions);
Exit;
end;
end;
end;


~Home

Narcle

2012-05-23 14:31:52

Speed wise?

Home

2012-05-23 14:38:03

From: Narcle
Speed wise?


Approx same speed as SRL's.

~Home

Narcle

2012-05-23 14:39:14

I don't see how scrolling speed can be as fast as when you click right to the spot.

Home

2012-05-23 15:13:26

Scrolling 2075 MS
Current One 3807 MS

Scrolling can do it very fast, If I would remove some humanity from it, which I don't wan't to do.

Mostly it's because it has to OrderWorlds. With scrolling it doesn't have to do that.

~Home

Runaway

2012-05-23 15:16:14

Could you add a click boolean?
"function FindWorldScroll(W :Integer; Click :Boolean) :Boolean;"

I would then suggest something like this, and it would be alot easier to be able to click the found world without having to re-find it to click it:


function RandomWorldScroll(Members: Boolean; Click: Boolean): Boolean;
var
Free, Member: TIntegerArray;
W: Integer;
begin
Result := False;
Free := [1, 4, 5 {more}];
Member := [2, 3, 6 {more}];
if Members then
W := Random(High(Member))
else
W := Random(High(Free));
if FindWorldScroll(W, Click) then
Result := True;
end;

Home

2012-05-23 15:18:54

From: Runaway
Could you add a click boolean?
"function FindWorldScroll(W :Integer; Click :Boolean) :Boolean;"

I would then suggest something like this, and it would be alot easier to be able to click the found world without having to re-find it to click it:


function RandomWorldScroll(Members: Boolean; Click: Boolean): Boolean;
var
Free, Members: TIntegerArray;
W: Integer;
begin
Result := False;
Free := [1, 4, 5 {more}];
Members := [2, 3, 6 {more}];
if Members then
W := Random(High(Members))
else
W := Random(High(Free));
if FindWorldScroll(W, Click) then
Result := True;
end;



Well yes, sure. But This works with current SRL Functions, that is the reason why I didn't make it click.


~Home

Runaway

2012-05-23 15:30:44

From: Home
Well yes, sure. But This works with current SRL Functions, that is the reason why I didn't make it click.


Oh wow, my bad :p

Just took a look at worldswitcher.simba for the first time ever and saw how useless my post was! I still do have a suggestion though, maybe just add scroll as a boolean in the original?


function SelectWorld(W: integer; Scroll: boolean): boolean;

Home

2012-05-23 15:32:32

From: Runaway
Oh wow, my bad :p

Just took a look at worldswitcher.simba for the first time ever and saw how useless my post was! I still do have a suggestion though, maybe just add scroll as a boolean in the original?


function SelectWorld(W: integer; Scroll: boolean): boolean;



That's true. Original one needs editing too though :S

And I really don't wan't break any scripts (Many scripts use ChangeWorld func)

And no worries :)

~Home

Narcle

2012-05-23 18:52:12

From: Home
Scrolling 2075 MS
Current One 3807 MS

Scrolling can do it very fast, If I would remove some humanity from it, which I don't wan't to do.

Mostly it's because it has to OrderWorlds. With scrolling it doesn't have to do that.

~Home


Ah true. Only concern I have is if for some people the scrolling will lag for them, as scrolling takes more processing. Otherwise yeah I'd put it in now.

Runaway

2012-05-23 20:05:53

From: Home
And I really don't wan't break any scripts (Many scripts use ChangeWorld func)



function SelectWorld(W: integer; Scroll: boolean): boolean;


Couldn't you do this for now until people are notified of the change, or whatever happens when you change a core function :p


function ChangeWorld(W: Integer): Boolean;
begin
if LoggedIn then
WaitFunc(@ExitToLobby, 500, 5000);
Result := SelectWorld(W, False);
LoginPlayer;
end;

Home

2012-05-24 11:22:42

From: Runaway
Couldn't you do this for now until people are notified of the change, or whatever happens when you change a core function :p


function ChangeWorld(W: Integer): Boolean;
begin
if LoggedIn then
WaitFunc(@ExitToLobby, 500, 5000);
Result := SelectWorld(W, False);
LoginPlayer;
end;


I'm sorry but I don't understand what you mean. currently you just Wait until ExitToLobby results True :S And after that just selecto world, but if you mean with Boolean that shall we use Scrolling or Normal then I understand.

Narcle. No, not really. this is not up to me as I'm not SRL Developer.

~Home

Runaway

2012-05-24 11:30:21

From: Home
if you mean with Boolean that shall we use Scrolling or Normal then I understand.


Bingo!

That's the current ChangeWorld func, I was just showing you that it wouldn't be broken if you just incorporate the false scroll boolean. Now that I think of it, you could do:


function ChangeWorld(W: Integer): Boolean;
begin
if LoggedIn then
WaitFunc(@ExitToLobby, 500, 5000);
Result := SelectWorld(W, False);
LoginPlayer;
end;


function ChangeWorldScroll(W: Integer): Boolean;
begin
if LoggedIn then
WaitFunc(@ExitToLobby, 500, 5000);
Result := SelectWorld(W, True);
LoginPlayer;
end;

That wouldn't break anything :)